-<?php // -*-php-*-
-// $Id: GoogleMaps.php 8212 2011-12-16 13:26:15Z vargenau $
+<?php
+
/**
* Copyright 2005 $ThePhpWikiProgrammingTeam
*
* Uses Google Maps as a Map Server
*
* This plugin displays a marker with further infos (when clicking) on given coordinates.
-
* Hint: You need to sign up for a Google Maps API key!
* http://www.google.com/apis/maps/signup.html
* Then enter the key in config/config.ini under GOOGLE_LICENSE_KEY=
* Automatic route following
*/
class WikiPlugin_GoogleMaps
-extends WikiPlugin
+ extends WikiPlugin
{
- function getName() {
- return _("GoogleMaps");
- }
-
- function getDescription() {
- return _("Displays a marker with further infos (when clicking) on given coordinates");
+ function getDescription()
+ {
+ return _("Display a marker with further infos (when clicking) on given coordinates.");
}
- function getDefaultArguments() {
+ function getDefaultArguments()
+ {
return array(
- 'Longitude' => '',
- 'Latitude' => '',
- 'ZoomFactor'=> 5,
- 'Marker' => true,
- 'InfoText' => '',
- 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
- 'SmallMapControl' => false, // large or small
- 'width' => '500px',
- 'height' => '400px',
- );
+ 'Longitude' => '',
+ 'Latitude' => '',
+ 'ZoomFactor' => 5,
+ 'Marker' => true,
+ 'InfoText' => '',
+ 'MapType' => 'Hybrid', // Map|Satellite|Hybrid,
+ 'SmallMapControl' => false, // large or small
+ 'width' => '500px',
+ 'height' => '400px',
+ );
}
- function run($dbi, $argstr, &$request, $basepage) {
- global $WikiTheme;
+ function run($dbi, $argstr, &$request, $basepage)
+ {
$args = $this->getArgs($argstr, $request);
extract($args);
if ($Longitude === '') {
- return $this->error(sprintf(_("A required argument '%s' is missing."), 'Longitude'));
+ return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Longitude'));
}
if ($Latitude === '') {
- return $this->error(sprintf(_("A required argument '%s' is missing."), 'Latitude'));
+ return $this->error(sprintf(_("A required argument ā%sā is missing."), 'Latitude'));
}
- $maps = JavaScript('',array('src'=>"http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
+ $maps = JavaScript('', array('src' => "http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
$id = GenerateId("googlemap");
switch ($MapType) {
- case "Satellite": $type = "_SATELLITE_TYPE"; break;
- case "Map": $type = "_MAP_TYPE"; break;
- case "Hybrid": $type = "_HYBRID_TYPE"; break;
- default: return $this->error(sprintf(_("Invalid argument %s"), $MapType));
+ case "Satellite":
+ $type = "_SATELLITE_TYPE";
+ break;
+ case "Map":
+ $type = "_MAP_TYPE";
+ break;
+ case "Hybrid":
+ $type = "_HYBRID_TYPE";
+ break;
+ default:
+ return $this->error(sprintf(_("Invalid argument %s"), $MapType));
}
- $div = HTML::div(array('id'=>$id,'style'=>'width: '.$width.'; height: '.$height));
+ $div = HTML::div(array('id' => $id, 'style' => 'width: ' . $width . '; height: ' . $height));
// TODO: Check for multiple markers or polygons
if (!$InfoText)
if ($InfoText) {
include_once 'lib/BlockParser.php';
$page = $dbi->getPage($request->getArg('pagename'));
- $rev = $page->getCurrentRevision(false);
+ $rev = $page->getCurrentRevision(false);
$markup = $rev->get('markup');
$markertext = TransformText($InfoText, $markup, $basepage);
}
function createMarker(point, text) {
var marker = new GMarker(point);
var html = text + \"<br><br><font size='-1'>[" .
- _("new window") .
- "]</font>\";
+ _("new window") .
+ "]</font>\";
GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});
return marker;
}");
}
$run = JavaScript("
-var map = new GMap(document.getElementById('".$id."'));\n" .
-($SmallMapControl
- ? "map.addControl(new GSmallMapControl());\n"
- : "map.addControl(new GLargeMapControl());\n") . "
+var map = new GMap(document.getElementById('" . $id . "'));\n" .
+ ($SmallMapControl
+ ? "map.addControl(new GSmallMapControl());\n"
+ : "map.addControl(new GLargeMapControl());\n") . "
map.addControl(new GMapTypeControl());
-map.centerAndZoom(new GPoint(".$Longitude.", ".$Latitude."), ".$ZoomFactor.");
-map.setMapType(".$type.");" .
-($Marker
- ? "
-var point = new GPoint(".$Longitude.",".$Latitude.");
-var marker = createMarker(point, '".$markertext->asXml()."'); map.addOverlay(marker);"
- : "")
-);
+map.centerAndZoom(new GPoint(" . $Longitude . ", " . $Latitude . "), " . $ZoomFactor . ");
+map.setMapType(" . $type . ");" .
+ ($Marker
+ ? "
+var point = new GPoint(" . $Longitude . "," . $Latitude . ");
+var marker = createMarker(point, '" . $markertext->asXml() . "'); map.addOverlay(marker);"
+ : "")
+ );
if ($Marker)
- return HTML($markerjs,$maps,$div,$run);
+ return HTML($markerjs, $maps, $div, $run);
else
- return HTML($maps,$div,$run);
+ return HTML($maps, $div, $run);
}
-};
+}
// Local Variables:
// mode: php