[gnome-maps] mapView: Add method to show a set of locations



commit c21833a4e81f136ffe1001f715cd7c2ac5fdfbc3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sun Mar 31 21:15:15 2013 +0300

    mapView: Add method to show a set of locations
    
    If there is only one location in the passed array, we simply 'go to'
    that location, as in mapView._goto_location().

 src/mapView.js |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 6588683..b6b061a 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -61,10 +61,18 @@ const MapView = new Lang.Class({
 
     geocodeSearch: function(string) {
         let forward = Geocode.Forward.new_for_string(string);
-        forward._searchString = string;
         this._markerLayer.remove_all();
 
-        forward.search_async (null, Lang.bind(this, this._onGeocodeSearchComplete));
+        forward.search_async (null, Lang.bind(this,
+            function(forward, res) {
+                try {
+                    locations = forward.search_finish(res);
+                    log (locations.length + " locations found");
+                    this._showLocations(locations);
+                } catch (e) {
+                    log ("Failed to search '" + string + "': " + e.message);
+                }
+            }));
     },
 
     _gotoLocation: function(location, accuracy) {
@@ -84,17 +92,7 @@ const MapView = new Lang.Class({
             }));
     },
 
-    _onGeocodeSearchComplete: function(forward, res) {
-        let locations = [];
-
-        try {
-            locations = forward.search_finish(res);
-        } catch (e) {
-            let str = forward.get_data ("string");
-            log ("Failed to search '" + forward._searchString + "': " + e.message);
-            return;
-        }
-        log (locations.length + " locations found");
+    _showLocations: function(locations) {
         if (locations.length == 0)
             return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]