From 08bc1023c638e441f840b556d0b725ecec9d1aa5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 24 Aug 2013 15:42:13 +0100 Subject: Pass the layers given in the OSM directive through This commit passes the layers given in the osm directive, defaulting to OSM if none are given, through to the page. As without this, things go wrong in the Javascript, as it tries to work with a null array of layers. --- IkiWiki/Plugin/osm.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/osm.pm b/IkiWiki/Plugin/osm.pm index c9650d014..aa117bae2 100644 --- a/IkiWiki/Plugin/osm.pm +++ b/IkiWiki/Plugin/osm.pm @@ -138,6 +138,15 @@ sub preprocess { ); } + # Default to just the OSM layer + my @layers = [ 'OSM' ]; + + # If the user has passed some layers in + if (defined $params{layers}) { + # Seperate the layers + @layers = [ split(/,/, $params{layers}) ]; + } + register_rendered_files($map, $page, $dest); $pagestate{$page}{'osm'}{$map}{'displays'}{$name} = { @@ -150,6 +159,7 @@ sub preprocess { lat => $lat, lon => $lon, href => $href, + layers => @layers, google_apikey => $config{'osm_google_apikey'}, }; return "
"; @@ -587,7 +597,6 @@ sub map_setup_code($;@) { if ($mapurl) { $options{'mapurl'} = $mapurl; } - $options{'layers'} = $config{osm_layers}; return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");"; } -- cgit v1.2.3