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
61 function getDescription()
63 return _("Display a marker with further infos (when clicking) on given coordinates.");
66 function getDefaultArguments()
74 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
75 'SmallMapControl' => false, // large or small
81 function run($dbi, $argstr, &$request, $basepage)
84 $args = $this->getArgs($argstr, $request);
87 if ($Longitude === '') {
88 return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Longitude'));
90 if ($Latitude === '') {
91 return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Latitude'));
94 $maps = JavaScript('', array('src' => "http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
95 $id = GenerateId("googlemap");
98 $type = "_SATELLITE_TYPE";
104 $type = "_HYBRID_TYPE";
107 return $this->error(sprintf(_("Invalid argument %s"), $MapType));
109 $div = HTML::div(array('id' => $id, 'style' => 'width: ' . $width . '; height: ' . $height));
111 // TODO: Check for multiple markers or polygons
114 // Create a marker whose info window displays the given text
117 include_once 'lib/BlockParser.php';
118 $page = $dbi->getPage($request->getArg('pagename'));
119 $rev = $page->getCurrentRevision(false);
120 $markertext = TransformText($InfoText, $basepage);
122 $markerjs = JavaScript("
123 function createMarker(point, text) {
124 var marker = new GMarker(point);
125 var html = text + \"<br><br><font size='-1'>[" .
126 _("new window") .
128 GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});
134 var map = new GMap(document.getElementById('" . $id . "'));\n" .
136 ? "map.addControl(new GSmallMapControl());\n"
137 : "map.addControl(new GLargeMapControl());\n") . "
138 map.addControl(new GMapTypeControl());
139 map.centerAndZoom(new GPoint(" . $Longitude . ", " . $Latitude . "), " . $ZoomFactor . ");
140 map.setMapType(" . $type . ");" .
143 var point = new GPoint(" . $Longitude . "," . $Latitude . ");
144 var marker = createMarker(point, '" . $markertext->asXml() . "'); map.addOverlay(marker);"
148 return HTML($markerjs, $maps, $div, $run);
150 return HTML($maps, $div, $run);
158 // c-hanging-comment-ender-p: nil
159 // indent-tabs-mode: nil