4 * Copyright 2005 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * Uses Google Maps as a Map Server
26 * This plugin displays a marker with further infos (when clicking) on given coordinates.
27 * Hint: You need to sign up for a Google Maps API key!
28 * http://www.google.com/apis/maps/signup.html
29 * Then enter the key in config/config.ini under GOOGLE_LICENSE_KEY=
39 * MapType=Map|Satellite|Hybrid
46 * @see plugin/GooglePlugin
47 * http://www.giswiki.de/index.php/Google_Maps_Extensions
48 * http://www.google.com/apis/maps/, http://maps.google.com/
49 * http://libgmail.sourceforge.net/googlemaps.html
52 * Search for keywords (search=)
53 * mult. markers would need a new syntax
54 * directions (from - to)
56 * Automatic route following
58 class WikiPlugin_GoogleMaps
63 return _("GoogleMaps");
66 function getDescription()
68 return _("Displays a marker with further infos (when clicking) on given coordinates");
71 function getDefaultArguments()
79 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
80 'SmallMapControl' => false, // large or small
86 function run($dbi, $argstr, &$request, $basepage)
89 $args = $this->getArgs($argstr, $request);
92 if ($Longitude === '') {
93 return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Longitude'));
95 if ($Latitude === '') {
96 return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Latitude'));
99 $maps = JavaScript('', array('src' => "http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
100 $id = GenerateId("googlemap");
103 $type = "_SATELLITE_TYPE";
109 $type = "_HYBRID_TYPE";
112 return $this->error(sprintf(_("Invalid argument %s"), $MapType));
114 $div = HTML::div(array('id' => $id, 'style' => 'width: ' . $width . '; height: ' . $height));
116 // TODO: Check for multiple markers or polygons
119 // Create a marker whose info window displays the given text
122 include_once 'lib/BlockParser.php';
123 $page = $dbi->getPage($request->getArg('pagename'));
124 $rev = $page->getCurrentRevision(false);
125 $markup = $rev->get('markup');
126 $markertext = TransformText($InfoText, $markup, $basepage);
128 $markerjs = JavaScript("
129 function createMarker(point, text) {
130 var marker = new GMarker(point);
131 var html = text + \"<br><br><font size='-1'>[" .
132 _("new window") .
134 GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});
140 var map = new GMap(document.getElementById('" . $id . "'));\n" .
142 ? "map.addControl(new GSmallMapControl());\n"
143 : "map.addControl(new GLargeMapControl());\n") . "
144 map.addControl(new GMapTypeControl());
145 map.centerAndZoom(new GPoint(" . $Longitude . ", " . $Latitude . "), " . $ZoomFactor . ");
146 map.setMapType(" . $type . ");" .
149 var point = new GPoint(" . $Longitude . "," . $Latitude . ");
150 var marker = createMarker(point, '" . $markertext->asXml() . "'); map.addOverlay(marker);"
154 return HTML($markerjs, $maps, $div, $run);
156 return HTML($maps, $div, $run);
164 // c-hanging-comment-ender-p: nil
165 // indent-tabs-mode: nil