[Commits] r1504 - in sandbox/cmoullet/ux/StreetViewPanel/ux: control widgets

commits at geoext.org commits at geoext.org
Thu Nov 26 23:59:44 CET 2009


Author: cmoullet
Date: 2009-11-26 23:59:44 +0100 (Thu, 26 Nov 2009)
New Revision: 1504

Modified:
   sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js
   sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Callback rearchitecture


Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js	2009-11-26 22:41:22 UTC (rev 1503)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js	2009-11-26 22:59:44 UTC (rev 1504)
@@ -32,27 +32,7 @@
         var lonlat = this.map.getLonLatFromViewPortPx(evt.xy);
         lonlat.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
         var clickedPosition = new GLatLng(lonlat.lat, lonlat.lon);
-
-        var callback = function (data) {
-            if (data) {
-                if (data.code == 600) {
-                    alert(OpenLayers.i18n('Google Street View: No panorama found near this position. You have to click elsewhere ;-)'));
-                } else if (data.code == 500) {
-                    alert(OpenLayers.i18n('Google Street View: Server error'));
-                } else if (data.code == 200) {
-                    var POV = {yaw: this.panorama.yaw,  pitch: this.panorama.pitch, zoom: this.panorama.zoom};
-                    this.panorama.setLocationAndPOV(data.location.latlng, POV);
-                    // Add the navigation tool
-                    if (this.panorama.showTool) {
-                        this.panorama.drawNavigationTool(this.panorama, data.location.latlng, data.links)
-                    }
-
-                } else {
-                    alert(OpenLayers.i18n('Google Street View: Unexpected problem'));
-                }
-            }
-        };
-        this.streetviewclient.getNearestPanorama(clickedPosition, callback.createDelegate(this));
+        this.streetviewclient.getNearestPanorama(clickedPosition, this.panorama.callback.createDelegate(this));
     },
 
     onDblclick: function(evt) {

Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-11-26 22:41:22 UTC (rev 1503)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-11-26 22:59:44 UTC (rev 1504)
@@ -137,10 +137,8 @@
             }
             this.yaw = yaw;
         });
-        // Set initial position of panorama
-        if (this.panoramaLocation) {
-            var POV = {yaw: this.panorama.yaw,  pitch: this.panorama.pitch, zoom: this.panorama.zoom};
-            var callback = function (data) {
+        // Callback to manage panorama
+        this.panorama.callback = function (data) {
                 if (data) {
                     if (data.code == 600) {
                         alert(OpenLayers.i18n('Google Street View: No panorama found near this position. You have to click elsewhere ;-)'));
@@ -159,7 +157,10 @@
                     }
                 }
             };
-            this.streetviewclient.getNearestPanorama(this.panoramaLocation, callback.createDelegate(this));
+        // Set initial position of panorama
+        if (this.panoramaLocation) {
+            var POV = {yaw: this.panorama.yaw,  pitch: this.panorama.pitch, zoom: this.panorama.zoom};
+            this.streetviewclient.getNearestPanorama(this.panoramaLocation, this.callback.createDelegate(this));
         }
 
         // Add features associated to map



More information about the Commits mailing list