2 rcs_id('$Id: GoogleMaps.php,v 1.1 2005-09-07 16:53:46 rurban Exp $');
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
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 class WikiPlugin_GoogleMaps
61 return _("GoogleMaps");
64 function getDescription() {
65 return _("Displays a marker with further infos (when clicking) on given coordinates");
68 function getVersion() {
69 return preg_replace("/[Revision: $]/", '',
73 function getDefaultArguments() {
81 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
82 'SmallMapControl' => false, // large or small
88 function run($dbi, $argstr, &$request, $basepage) {
91 $args = $this->getArgs($argstr, $request);
94 if ($Longitude === '') {
95 return $this->error(fmt("%s parameter missing", "'Longitude'"));
97 if ($Latitude === '') {
98 return $this->error(fmt("%s parameter missing", "'Latitude'"));
100 if ($InfoLink and ! IsSafeURL($InfoLink)) {
101 return $this->error(sprintf(_("Bad url in %s: remove all of <, >, \""), "InfoLink"));
107 if (!$InfoLink and $InfoText)
108 $InfoLink = $InfoText;
109 $markerlink = HTML::a(array('href'=>$InfoLink,'target'=>"_blank"),
111 // Creates a marker whose info window displays the given number
112 $markerjs = JavaScript("
113 function createMarker(point, text) {
114 var marker = new GMarker(point);
115 var html = text + \"<br><br><font size='-1'>[" .
116 _("new window") .
118 GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});
122 $maps = JavaScript('',array('src'=>"http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
123 $id = GenerateId("googlemap");
125 case "Satellite": $type = "_SATELLITE_TYPE"; break;
126 case "Map": $type = "_MAP_TYPE"; break;
127 case "Hybrid": $type = "_HYBRID_TYPE"; break;
128 default: return $this->error(sprintf(_("invalid argument %s"), $MapType));
130 $div = HTML::div(array('id'=>$id,'style'=>'width: '.$width.'; height: '.$height));
132 var map = new GMap(document.getElementById('".$id."'));\n" .
134 ? "map.addControl(new GSmallMapControl());\n"
135 : "map.addControl(new GLargeMapControl());\n") . "
136 map.addControl(new GMapTypeControl());
137 map.centerAndZoom(new GPoint(".$Longitude.", ".$Latitude."), ".$ZoomFactor.");
138 map.setMapType(".$type.");
139 var point = new GPoint(".$Longitude.",".$Latitude.");\n" .
141 ? "var marker = createMarker(point, '".$markerlink->asXml()."'); map.addOverlay(marker);\n"
145 return HTML($markerjs,$maps,$div,$run);
147 return HTML($maps,$div,$run);
151 // $Log: not supported by cvs2svn $
154 // (c-file-style: "gnu")
159 // c-hanging-comment-ender-p: nil
160 // indent-tabs-mode: nil