<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><br>I have succeeded to generate tiles of my country using mapnik.<br>
I would like to know how to use OpenLayers to obtain a slippy map of my country in local .<br><br></div></blockquote></div><br>Hi,<br> this is the code i&#39;m using to load mapnik local tiles stored in &quot;/var/www/openlayer/tiles/&quot; directory (in particular see the bold code):<br>
<br>------------------------------------<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Esempio di marker GML con identificazione degli attributi&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;../theme/default/style.css&quot; type=&quot;text/css&quot; /&gt;<br>
    &lt;link rel=&quot;stylesheet&quot; href=&quot;../theme/default/framedCloud.css&quot; type=&quot;text/css&quot; /&gt;<br>        &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot; /&gt;<br>
    &lt;style type=&quot;text/css&quot;&gt;<br>        #map {<br>            width: 800px; <br>            height: 600px; <br>            border: 1px solid black;<br>        }<br>        .olPopup p { margin:0px; }<br>    &lt;/style&gt;<br>
    &lt;script src=&quot;../lib/OpenLayers.js&quot;&gt;&lt;/script&gt;<br>    &lt;!--&lt;script src=&quot;<a href="http://www.openstreetmap.org/openlayers/OpenStreetMap.js">http://www.openstreetmap.org/openlayers/OpenStreetMap.js</a>&quot;&gt;&lt;/script&gt;--&gt;<br>
    &lt;script src=&quot;../OpenStreetMap.js&quot;&gt;&lt;/script&gt;<br><br><br>     &lt;script type=&quot;text/javascript&quot;&gt;<br>        // Start position for the map (hardcoded here for simplicity,<br>        // but maybe you want to get from URL params)<br>
        var lat=45.5060<br>        var lon=11.41<br>        var zoom=13<br>        var map, layer;<br><br>        var symbolizer = OpenLayers.Util.applyDefaults(<br>//         {externalGraphic: &quot;./balloon_blue_sh.png&quot;, pointRadius: 10},<br>
             {fillColor:&#39;red&#39;, fillOpacity: 0.9, strokeColor: &quot;orange&quot;, strokeWidth: &quot;6&quot;, strokeOpacity: 0.6},<br>            OpenLayers.Feature.Vector.style[&quot;default&quot;]);<br>        styleMap = new OpenLayers.StyleMap({&quot;default&quot;: symbolizer}); <br>
<br>    function init(){<br>            map = new OpenLayers.Map (&quot;map&quot;, {<br>                controls:[<br>                    new OpenLayers.Control.Navigation(),<br>                    new OpenLayers.Control.PanZoomBar(),<br>
                    new OpenLayers.Control.LayerSwitcher(),<br>                    new OpenLayers.Control.Attribution()],<br>                maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br>
                maxResolution: 156543.0399,<br>                numZoomLevels: 19,<br>                units: &#39;m&#39;,<br>                //projection: new OpenLayers.Projection(&quot;EPSG:900913&quot;),<br>                displayProjection: new OpenLayers.Projection(&quot;EPSG:4326&quot;)<br>
            } );<br><br>     <br>        <br>        <b>var newLayer = new OpenLayers.Layer.OSM(&quot;Mapnik@home&quot;, &quot;<a href="http://localhost/openlayer/tiles/">http://localhost/openlayer/tiles/</a>&quot;, {numZoomLevels: 19});<br>
         map.addLayer(newLayer);</b><br>     <br><br><br>             map.addLayer(new OpenLayers.Layer.GML(&quot;Siti di interesse&quot;, &quot;siti_int.gml&quot;, <br>                {styleMap: styleMap,<br>                 format: OpenLayers.Format.GML, <br>
                 formatOptions: {<br>                   extractStyles: true, <br>                   extractAttributes: true<br>                 }<br>            <br>                }));<br><br>        <br>        map.addLayer(new OpenLayers.Layer.GML(&quot;GML lungo&quot;, &quot;../track/baciccio.gml&quot;, {styleMap: styleMap}));<br>
             map.addLayer(new OpenLayers.Layer.GML(&quot;GML corto&quot;, &quot;../track/data_track.gml&quot;, &quot;#ff0000&quot;));<br>    <br>        // aggiunta della navtoolbar<br>        var panel = new OpenLayers.Control.NavToolbar({&#39;div&#39;:OpenLayers.Util.getElement(&#39;paneldiv&#39;)});<br>
            map.addControl(panel);<br>        // fine aggiunta navtoolbar<br><br><br>        selectControl = new OpenLayers.Control.SelectFeature(map.layers[1],<br>                {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});<br>
  <br>            map.addControl(selectControl);<br>            selectControl.activate();   <br>            //map.zoomToMaxExtent();<br><br>        <br>        var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection(&quot;EPSG:4326&quot;), map.getProjectionObject());<br>
            map.setCenter (lonLat, zoom);<br>               <br>        <br>        }<br><br>    function onPopupClose(evt) {<br>            selectControl.unselect(selectedFeature);<br>        }<br><br><br><br>// script per la visualizzazione degli attributi del file GML su un Ballon<br>
<br>          function onFeatureSelect(feature) {<br>              selectedFeature = feature;<br>         <br>          for(var key in feature.attributes)<br>          <br>              popup = new OpenLayers.Popup.FramedCloud(&quot;chicken&quot;, <br>
                                       feature.geometry.getBounds().getCenterLonLat(),<br>                                       new OpenLayers.Size(100,100), &quot;&lt;div style=&#39;font-size:16&#39;&gt;&quot;+feature.attributes.nome + &quot;&lt;/div&gt;&quot; + &quot;&lt;div style=&#39;font-size:13&#39;&gt;&quot; + &quot;descrizione: &quot; +feature.attributes.descriz + &quot;&lt;/div&gt;&quot; + &quot;&lt;div style=&#39;font-size:13&#39;&gt;&quot; +feature.attributes.img + &quot;&lt;/div&gt;&quot;, null, true, onPopupClose);<br>
              feature.popup = popup;<br>              map.addPopup(popup);<br>          }<br><br><br><br>        function onFeatureUnselect(feature) {<br>            map.removePopup(feature.popup);<br>            feature.popup.destroy();<br>
            feature.popup = null;<br>        }<br><br>        <br><br>    &lt;/script&gt;<br> <br>&lt;/head&gt;<br>&lt;body onload=&quot;init()&quot;&gt;<br>      &lt;h1 id=&quot;title&quot;&gt;Esempio di Layer GML&lt;/h1&gt;<br>
<br>      &lt;div id=&quot;tags&quot;&gt;&lt;/div&gt;<br><br>      &lt;p id=&quot;shortdesc&quot;&gt;<br>          Caricamento e visualizzazione di un file GML su base OSM.<br>    &lt;/p&gt;<br><br>    &lt;div id=&quot;map&quot; align=&quot;right&quot;&gt;&lt;/div&gt;<br>
<br>    <br>    &lt;!--aggiunta del navtoolbar --&gt;<br>    &lt;div id=&quot;paneldiv&quot; class=&quot;olControlNavToolbar&quot;&gt;&lt;/div&gt;<br>    &lt;!--fine aggiunta del navtoolbar --&gt;<br>    &lt;div id=&quot;docs&quot;&gt;&lt;/div&gt;<br>
  &lt;/body&gt;<br>&lt;/html&gt;<br><br clear="all">------------------------------------------------------------<br><br>hope this help<br>flavio<br><br>-- <br>io uso Debian GNU/Linux<br>user #413018 <a href="http://counter.li.org">counter.li.org</a><br>
<br>&lt;&lt;usiamo formati aperti!&gt;&gt; <br><a href="http://it.wikipedia.org/wiki/Formato_aperto">http://it.wikipedia.org/wiki/Formato_aperto</a><br>