http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89773
Revision: 89773
Author: jeroendedauw
Date: 2011-06-09 16:27:24 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
applied patch by Desiree Gennaro
Modified Paths:
--------------
branches/Maps0.7.x/RELEASE-NOTES
branches/Maps0.7.x/includes/geocoders/Maps_GoogleGeocoder.php
Modified: branches/Maps0.7.x/RELEASE-NOTES
===================================================================
--- branches/Maps0.7.x/RELEASE-NOTES 2011-06-09 16:27:03 UTC (rev 89772)
+++ branches/Maps0.7.x/RELEASE-NOTES 2011-06-09 16:27:24 UTC (rev 89773)
@@ -16,6 +16,8 @@
* Removed dead code (initial code to support the RL, now used in SM 1.0 and
later).
+* Use of Google Maps geocoding service v3 instead of v2.
+
=== Maps 0.7.6 ===
(2011-03-21)
Modified: branches/Maps0.7.x/includes/geocoders/Maps_GoogleGeocoder.php
===================================================================
--- branches/Maps0.7.x/includes/geocoders/Maps_GoogleGeocoder.php
2011-06-09 16:27:03 UTC (rev 89772)
+++ branches/Maps0.7.x/includes/geocoders/Maps_GoogleGeocoder.php
2011-06-09 16:27:24 UTC (rev 89773)
@@ -1,16 +1,18 @@
<?php
/**
- * Class for geocoding requests with the Google Geocoding Service (v2).
+ * Class for geocoding requests with the Google Geocoding Service (v3).
*
- * Webservice documentation:
http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct
+ * Webservice documentation:
http://code.google.com/apis/maps/documentation/geocoding/
*
* @file Maps_GoogleGeocoder.php
* @ingroup Maps
* @ingroup Geocoders
*
- * @author Jeroen De Dauw
+ * @licence GNU GPL v3
+ * @author Jeroen De Dauw < [email protected] >
* @author Sergey Chernyshev
+ * @author Desiree Gennaro
*/
final class MapsGoogleGeocoder extends MapsGeocoder {
@@ -37,8 +39,7 @@
* @return string
*/
protected function getRequestUrl( $address ) {
- global $egGoogleMapsKey;
- return 'http://maps.google.com/maps/geo?q=' . urlencode(
$address ) . '&output=csv&key=' . urlencode( $egGoogleMapsKey );
+ return
'http://maps.googleapis.com/maps/api/geocode/xml?address=' . urlencode(
$address ) . '&sensor=false';
}
/**
@@ -51,20 +52,16 @@
* @return array
*/
protected function parseResponse( $response ) {
- // Check the Google Geocoder API Response code to ensure
success.
- if ( substr( $response, 0, 3 ) == '200' ) {
- $result = explode( ',', $response );
-
- // $precision = $result[1];
+ $lon = self::getXmlElementValue( $response, 'lng' );
+ $lat = self::getXmlElementValue( $response, 'lat' );
- return array(
- 'lat' => $result[2],
- 'lon' => $result[3]
- );
- }
- else { // When the request fails, return false.
- return false;
- }
+ // In case on of the values is not found, return false.
+ if ( !$lon || !$lat ) return false;
+
+ return array(
+ 'lat' => $lat,
+ 'lon' => $lon
+ );
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs