X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/d5b2dfd0e4fa3416f8396bb07f35c365e056648b..05decdadcba70e6304375987315d2f5dd00df98a:/IkiWiki/Plugin/osm.pm diff --git a/IkiWiki/Plugin/osm.pm b/IkiWiki/Plugin/osm.pm index 764767525..f570f4032 100644 --- a/IkiWiki/Plugin/osm.pm +++ b/IkiWiki/Plugin/osm.pm @@ -67,7 +67,20 @@ sub getsetup () { safe => 0, rebuild => 1, }, - + osm_layers => { + type => "string", + example => { 'OSM', 'GoogleSatellite' }, + description => "Layers to use in the map. Can be either the 'OSM' string or a type option for Google maps (GoogleNormal, GoogleSatellite, GoogleHybrid or GooglePhysical). It can also be an arbitrary URL in a syntax acceptable for OpenLayers.Layer.OSM.url parameter.", + safe => 0, + rebuild => 1, + }, + osm_google_apikey => { + type => "string", + example => "", + description => "Google maps API key, Google layer not used if missing, see https://code.google.com/apis/console/ to get an API key", + safe => 1, + rebuild => 1, + }, } sub register_rendered_files { @@ -137,6 +150,7 @@ sub preprocess { lat => $lat, lon => $lon, href => $href, + google_apikey => $config{'osm_google_apikey'}, }; return "
"; } @@ -520,6 +534,7 @@ sub cgi($) { zoom => "urlParams['zoom']", fullscreen => 1, editable => 1, + google_apikey => $config{'osm_google_apikey'}, ); print ""; print ""; @@ -530,9 +545,13 @@ sub cgi($) { sub embed_map_code(;$) { my $page=shift; my $olurl = $config{osm_openlayers_url} || "http://www.openlayers.org/api/OpenLayers.js"; - return ''. + my $code = ''."\n". ''."\n"; + if ($config{'osm_google_apikey'}) { + $code .= ''; + } + return $code; } sub map_setup_code($;@) { @@ -540,6 +559,8 @@ sub map_setup_code($;@) { my $name=shift; my %options=@_; + my $mapurl = $config{osm_map_url}; + eval q{use JSON}; error $@ if $@; @@ -556,6 +577,11 @@ sub map_setup_code($;@) { $options{'kmlurl'} = urlto($map."/pois.kml"); } + if ($mapurl) { + $options{'mapurl'} = $mapurl; + } + $options{'layers'} = $config{osm_layers}; + return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");"; }