diff options
author | Antoine Beaupré <anarcat@koumbit.org> | 2012-08-09 01:07:20 -0400 |
---|---|---|
committer | Antoine Beaupré <anarcat@koumbit.org> | 2012-08-25 08:20:30 -0400 |
commit | acc4d7d7d65ed9519fa9b5fca7c878f3e9a31451 (patch) | |
tree | e64f4c3ebb17adf5090f55362195ab28aa756bc4 /IkiWiki | |
parent | b57cad3131218c7d1a027a60c71ede74f0f14829 (diff) | |
download | ikiwiki-acc4d7d7d65ed9519fa9b5fca7c878f3e9a31451.tar ikiwiki-acc4d7d7d65ed9519fa9b5fca7c878f3e9a31451.tar.gz |
osm: add optional google maps support
for google maps to work, an API key needs to be added to the configuration
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/osm.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/osm.pm b/IkiWiki/Plugin/osm.pm index 21d1dce3f..d86dbd66e 100644 --- a/IkiWiki/Plugin/osm.pm +++ b/IkiWiki/Plugin/osm.pm @@ -74,7 +74,13 @@ sub getsetup () { 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 { @@ -144,6 +150,7 @@ sub preprocess { lat => $lat, lon => $lon, href => $href, + google_apikey => $config{'osm_google_apikey'}, }; return "<div id=\"mapdiv-$name\"></div>"; } @@ -527,6 +534,7 @@ sub cgi($) { zoom => "urlParams['zoom']", fullscreen => 1, editable => 1, + google_apikey => $config{'osm_google_apikey'}, ); print "</script>"; print "</body></html>"; @@ -537,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 '<script src="'.$olurl.'" type="text/javascript" charset="utf-8"></script>'. + my $code = '<script src="'.$olurl.'" type="text/javascript" charset="utf-8"></script>'."\n". '<script src="'.urlto("ikiwiki/osm.js", $page). '" type="text/javascript" charset="utf-8"></script>'."\n"; + if ($config{'osm_google_apikey'}) { + $code .= '<script src="http://maps.google.com/maps?file=api&v=2&key='.$config{'osm_google_apikey'}.'&sensor=false" type="text/javascript" charset="utf-8"></script>'; + } + return $code; } sub map_setup_code($;@) { |