r55815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55814‎ | r55815 | r55816 >
Date:12:53, 4 September 2009
Author:emiller
Status:deferred
Tags:
Comment:
* Support v2 of Static Maps API (v1 is deprecated)
* Fix links generated by Special:GoogleMapsKML
Modified paths:
  • /trunk/extensions/GoogleMaps/SpecialGoogleMapsKML.php (modified) (history)
  • /trunk/extensions/GoogleMaps/export/GoogleMapsImgExporter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleMaps/export/GoogleMapsImgExporter.php
@@ -2,51 +2,49 @@
33
44 class GoogleMapsImgExporter extends GoogleMapsExporter {
55 var $mApiKey;
6 - var $mPathCount;
76 var $mLanguageCode;
87
98 function GoogleMapsImgExporter($pApiKey, $pLanguageCode) {
109 $this->mApiKey = $pApiKey;
11 - $this->mPathCount = 0;
1210 $this->mLanguageCode = $pLanguageCode;
1311 }
1412
1513 function addHeader($o) {
16 - $width = $o['width'] > 512 ? 512 : $o['width'];
17 - $height = $o['height'] > 512 ? 512 : $o['height'];
 14+ $width = $o['width'] > 640 ? 640 : $o['width'];
 15+ $height = $o['height'] > 640 ? 640 : $o['height'];
1816 $this->mOutput .= '<img ';
1917 $this->mOutput .= "alt=\"Map\" ";
2018 $this->mOutput .= "height=\"{$height}\" width=\"{$width}\" ";
21 - $this->mOutput .= 'src="http://maps.google.com/staticmap';
 19+ $this->mOutput .= 'src="http://maps.google.com/maps/api/staticmap';
2220 $this->mOutput .= "?center={$o['lat']}%2C{$o['lon']}";
2321 $this->mOutput .= "&zoom={$o['zoom']}";
2422 $this->mOutput .= "&size={$width}x{$height}";
2523 $this->mOutput .= "&key={$this->mApiKey}";
26 - $this->mOutput .= "&hl={$this->mLanguageCode}";
27 - $this->mOutput .= "&markers=";
 24+ $this->mOutput .= "&language={$this->mLanguageCode}";
 25+ $this->mOutput .= "&sensor=false";
 26+ if ($o['type'] == 'terrain' || $o['type'] == 'satellite' || $o['type'] == 'hybrid') {
 27+ $this->mOutput .= "&maptype={$o['type']}";
 28+ }
2829 }
2930
3031 function addMarker($pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine)
3132 {
32 - if ($this->mPathCount == 0) {
33 - $label = '';
34 - if ($pIcon) {
35 - $label = strtolower(substr($pIcon, 0, 1));
36 - }
37 - $this->mOutput .= urlencode("{$pLat},{$pLon},red{$label}|");
 33+ $this->mOutput .= "&markers=".urlencode("size:mid|color:red");
 34+ if ($pIcon) {
 35+ $this->mOutput .= urlencode("|label:" . strtoupper(substr($pIcon, 0, 1)));
3836 }
 37+ $this->mOutput .= urlencode("|{$pLat},{$pLon}");
3938 }
4039
4140 function addPolyline( $pPolyline, $pLineColor, $pLineOpacity, $pStroke, $pFillColor, $pFillOpacity )
4241 {
43 - if ($this->mPathCount == 0) { # limit 1
44 - $this->mPathCount++;
45 - $this->mOutput .= "&path=";
46 - $this->mOutput .= urlencode("rgba:0x{$pLineColor}{$pLineOpacity},weight:{$pStroke}");
47 - foreach ($pPolyline as $p) {
48 - $this->mOutput .= urlencode("|{$p['lat']},{$p['lon']}");
49 - }
 42+ $this->mOutput .= "&path=".urlencode("color:0x{$pLineColor}{$pLineOpacity}|weight:{$pStroke}");
 43+ if ( isset( $pFillColor ) ) {
 44+ $this->mOutput .= urlencode("|fillcolor:0x{$pFillColor}{$pFillOpacity}");
5045 }
 46+ foreach ($pPolyline as $p) {
 47+ $this->mOutput .= urlencode("|{$p['lat']},{$p['lon']}");
 48+ }
5149 }
5250
5351 function addTrailer() {
Index: trunk/extensions/GoogleMaps/SpecialGoogleMapsKML.php
@@ -9,7 +9,7 @@
1010
1111 class GoogleMapsKML extends SpecialPage {
1212 function GoogleMapsKML() {
13 - parent::SpecialPage('Google Maps KML', '', false /* listed */);
 13+ parent::SpecialPage('GoogleMapsKML', '', false /* listed */);
1414 }
1515 function execute( $params ) {
1616 global $wgRequest, $wgOut, $wgTitle, $wgUser;

Status & tagging log