http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89772

Revision: 89772
Author:   jeroendedauw
Date:     2011-06-09 16:27:03 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
applied patch by Desiree Gennaro

Modified Paths:
--------------
    trunk/extensions/Maps/RELEASE-NOTES
    trunk/extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php

Modified: trunk/extensions/Maps/RELEASE-NOTES
===================================================================
--- trunk/extensions/Maps/RELEASE-NOTES 2011-06-09 15:42:23 UTC (rev 89771)
+++ trunk/extensions/Maps/RELEASE-NOTES 2011-06-09 16:27:03 UTC (rev 89772)
@@ -7,7 +7,7 @@
 http://mapping.referata.com/wiki/Maps/Version_history#Maps_change_log
 
 
-=== Maps 0.8 ===
+=== Maps 1.0 ===
 (2011-0x-xx)
 
 This version branched from Maps 0.7.x at version 0.7.3.
@@ -38,6 +38,8 @@
 
 * Improved KML formatter.
 
+* Use of Google Maps geocoding service v3 instead of v2.
+
 ==== Bug fixes ====
 
 * Fixed geocoding service overriding based on mapping service (merged in from 
Maps 0.7.5).

Modified: trunk/extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php
===================================================================
--- trunk/extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php    
2011-06-09 15:42:23 UTC (rev 89771)
+++ trunk/extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php    
2011-06-09 16:27:03 UTC (rev 89772)
@@ -1,9 +1,9 @@
 <?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
@@ -12,6 +12,7 @@
  * @licence GNU GPL v3
  * @author Jeroen De Dauw < [email protected] >
  * @author Sergey Chernyshev
+ * @author Desiree Gennaro
  */
 final class MapsGoogleGeocoder extends MapsGeocoder {
        
@@ -38,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';
        }
        
        /**
@@ -52,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

Reply via email to