User:SK53/OpenLayers

From OpenStreetMap Wiki
Jump to navigation Jump to search

I'd always had the idea that OL was too techy for me. However I've recently started rendering tiles using Mapnik & I want to see how they look.

What I use

  • OSGEO4W Apache Server. No particular reason other than as I use this package for accessing gdal/ogr etc., its installed.
  • Basic OL example from the OpenLayers site.(Spherical Mercator [1]).
  • Apache Service Monitor (from another Apache install). Merely to switch apache on & off.
  • a single tile directory (more to come)

What I've done

  • Register tiles in Apache by adding a file in OSGeo4Win\httpd.d called httpd_tiles.conf

Alias /tiles/ "dir-path/mapnik/maptiles/"

<Directory "dir-path/mapnik/maptiles/">

 AllowOverride None
 Options Indexes FollowSymLinks Multiviews 
 Order allow,deny
 Allow from all

</Directory>

  • Add these lines to the example HTML file
   // create LOSM layer
   var losm = new OpenLayers.Layer.OSM(
       "OpenStreetMap (Local)",
       "http://localhost/tiles/${z}/${x}/${y}.png",

{ // options isBaseLayer: true,

       numZoomLevels:21
       }
   );
The various zoom level options seem to be slightly non-intuitive. The numZoomLevels was the one which enabled me to see z19 and z20 tiles. See this for example