[OpenLayers-Commits] r7524 - sandbox/topp/almanac/lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Wed Jul 16 10:23:33 EDT 2008


Author: sbenthall
Date: 2008-07-16 10:23:32 -0400 (Wed, 16 Jul 2008)
New Revision: 7524

Modified:
   sandbox/topp/almanac/lib/OpenLayers/Control/YahooGeocoder.js
Log:
YahooGeocoder now parses response, transforms projection, and returns object

Modified: sandbox/topp/almanac/lib/OpenLayers/Control/YahooGeocoder.js
===================================================================
--- sandbox/topp/almanac/lib/OpenLayers/Control/YahooGeocoder.js	2008-07-16 13:30:15 UTC (rev 7523)
+++ sandbox/topp/almanac/lib/OpenLayers/Control/YahooGeocoder.js	2008-07-16 14:23:32 UTC (rev 7524)
@@ -85,30 +85,38 @@
         if(!callback) {
             callback = function() {};
         }
-        var bound = OpenLayers.Function.bind(function(request) {
-            
+        var requestCallback = function(request) {
             if(request.status >= 200 && request.status < 300) {
                 // success
+                var response = request.responseXML;
+                
+                var result = response.getElementsByTagName("Result")[0];
+                
                 var xml = new OpenLayers.Format.XML();
-                   
-                response = xml.read(request.response)
+                
+                var precision = xml.getAttributeNS(result, null, 'precision');
+                
+                var latitude = result.getElementsByTagName("Latitude")[0].firstChild.nodeValue;
+                var longitude = result.getElementsByTagName("Longitude")[0].firstChild.nodeValue;
+                
+                var lonlat = new OpenLayers.LonLat(longitude, latitude);
+                
+                lonlat.transform(this.serverProj, this.clientProj);
                     
-                OpenLayers.Console.log(response);
+                var obj = {
+                    precision : precision,
+                    lonlat : lonlat
+                }
+                
+                callback(obj);
             } else {
                 // failure
             }
-            
-            var lonlat = null;
-            if(point) {
-                var lonlat = new OpenLayers.LonLat(point.lng(), point.lat());
-                lonlat.transform(this.serverProj, this.clientProj);
-            }
-            callback(lonlat);
-        }, this);
+        };
 
         this.request = OpenLayers.Request.GET({
             url: this.yahooUrl,
-            callback: bound,
+            callback: requestCallback,
             params: params,
             scope: this
         });        



More information about the Commits mailing list