]> scripts.mit.edu Git - www/ikiwiki.git/commitdiff
OSM plugin: new config option to specify the url to fetch maps from
authorGeneviève Bastien <gbastien@versatic.net>
Tue, 7 Aug 2012 03:00:31 +0000 (23:00 -0400)
committerAntoine Beaupré <anarcat@koumbit.org>
Sat, 25 Aug 2012 12:20:30 +0000 (08:20 -0400)
IkiWiki/Plugin/osm.pm
underlays/osm/ikiwiki/osm.js

index 764767525485d9df1fda2175ec5e5e0c1f832f0e..21d1dce3f2f9692373a4f582009e8570a8cf9311 100644 (file)
@@ -67,6 +67,13 @@ sub getsetup () {
                        safe => 0,
                        rebuild => 1,
                },
+               osm_map_url => {
+                       type => "string",
+                       example => "/tiles/\${z}/\${x}/\${y}.png",
+                       description => "Url to get map tiles from (if none specified, uses the openstreetmap server, see http://wiki.openstreetmap.org/wiki/Creating_your_own_tiles for more info on serving your own tiles)",
+                       safe => 0,
+                       rebuild => 1,
+               },
 
 }
 
@@ -540,6 +547,8 @@ sub map_setup_code($;@) {
        my $name=shift;
        my %options=@_;
 
+       my $mapurl = $config{osm_map_url};
+
        eval q{use JSON};
        error $@ if $@;
                                
@@ -556,6 +565,10 @@ sub map_setup_code($;@) {
                $options{'kmlurl'} = urlto($map."/pois.kml");
        }
 
+       if ($mapurl) {
+               $options{'mapurl'} = $mapurl;
+       }
+
        return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");";
 }
 
index d7e3d53f42e7c832423d21ea6b82b1305ddec22d..644d4b57381a045f86e7c88029630c13ee266ba2 100644 (file)
@@ -37,8 +37,13 @@ function mapsetup(divname, options) {
                numZoomLevels: 18
        });
 
+       if (options.mapurl) {
+               var newLayer = new OpenLayers.Layer.OSM("Local Tiles", options.mapurl, {numZoomLevels: 19, isBaseLayer: true});
+               map.addLayer(newLayer);
+       } else {
+               map.addLayer(new OpenLayers.Layer.OSM());
+       }
 
-       map.addLayer(new OpenLayers.Layer.OSM());
        if (options.format == 'CSV') {
                pois = new OpenLayers.Layer.Text( "CSV",
                        { location: options.csvurl,