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.
28 * Hint: You need to sign up for a Google Maps API key!
29 * http://www.google.com/apis/maps/signup.html
30 * Then enter the key in config/config.ini under GOOGLE_LICENSE_KEY=
40 * MapType=Map|Satellite|Hybrid
47 * @see plugin/GooglePlugin
48 * http://www.giswiki.de/index.php/Google_Maps_Extensions
49 * http://www.google.com/apis/maps/, http://maps.google.com/
50 * http://libgmail.sourceforge.net/googlemaps.html
53 * Search for keywords (search=)
54 * mult. markers would need a new syntax
55 * directions (from - to)
57 * Automatic route following
59 class WikiPlugin_GoogleMaps
63 return _("GoogleMaps");
66 function getDescription() {
67 return _("Displays a marker with further infos (when clicking) on given coordinates");
70 function getDefaultArguments() {
77 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
78 'SmallMapControl' => false, // large or small
84 function run($dbi, $argstr, &$request, $basepage) {
86 $args = $this->getArgs($argstr, $request);
89 if ($Longitude === '') {
90 return $this->error(sprintf(_("A required argument '%s' is missing."), 'Longitude'));
92 if ($Latitude === '') {
93 return $this->error(sprintf(_("A required argument '%s' is missing."), 'Latitude'));
96 $maps = JavaScript('',array('src'=>"http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
97 $id = GenerateId("googlemap");
99 case "Satellite": $type = "_SATELLITE_TYPE"; break;
100 case "Map": $type = "_MAP_TYPE"; break;
101 case "Hybrid": $type = "_HYBRID_TYPE"; break;
102 default: return $this->error(sprintf(_("Invalid argument %s"), $MapType));
104 $div = HTML::div(array('id'=>$id,'style'=>'width: '.$width.'; height: '.$height));
106 // TODO: Check for multiple markers or polygons
109 // Create a marker whose info window displays the given text
112 include_once 'lib/BlockParser.php';
113 $page = $dbi->getPage($request->getArg('pagename'));
114 $rev = $page->getCurrentRevision(false);
115 $markup = $rev->get('markup');
116 $markertext = TransformText($InfoText, $markup, $basepage);
118 $markerjs = JavaScript("
119 function createMarker(point, text) {
120 var marker = new GMarker(point);
121 var html = text + \"<br><br><font size='-1'>[" .
122 _("new window") .
124 GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});
130 var map = new GMap(document.getElementById('".$id."'));\n" .
132 ? "map.addControl(new GSmallMapControl());\n"
133 : "map.addControl(new GLargeMapControl());\n") . "
134 map.addControl(new GMapTypeControl());
135 map.centerAndZoom(new GPoint(".$Longitude.", ".$Latitude."), ".$ZoomFactor.");
136 map.setMapType(".$type.");" .
139 var point = new GPoint(".$Longitude.",".$Latitude.");
140 var marker = createMarker(point, '".$markertext->asXml()."'); map.addOverlay(marker);"
144 return HTML($markerjs,$maps,$div,$run);
146 return HTML($maps,$div,$run);
154 // c-hanging-comment-ender-p: nil
155 // indent-tabs-mode: nil