[Commits] r1489 - sandbox/cmoullet/ux/StreetViewPanel/ux/control

commits at geoext.org commits at geoext.org
Wed Nov 25 16:17:30 CET 2009


Author: cmoullet
Date: 2009-11-25 16:17:30 +0100 (Wed, 25 Nov 2009)
New Revision: 1489

Modified:
   sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
Log:
Recenter on click

Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js	2009-11-25 07:42:18 UTC (rev 1488)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js	2009-11-25 15:17:30 UTC (rev 1489)
@@ -18,22 +18,37 @@
     },
 
     initialize: function(options) {
-        this.handlerOptions = OpenLayers.Util.extend(
-        {}, this.defaultHandlerOptions
-                );
-        OpenLayers.Control.prototype.initialize.apply(
-                this, arguments
-                );
+        this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
+        OpenLayers.Control.prototype.initialize.apply(this, arguments);
         this.handler = new OpenLayers.Handler.Click(
                 this, {
-            'click': this.onClick,
-            'dblclick': this.onDblclick
-        }, this.handlerOptions
-                );
+                   'click': this.onClick,
+                   'dblclick': this.onDblclick
+                },
+         this.handlerOptions
+         );
     },
 
+
     onClick: function(evt) {
-        alert('click');
+        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('No panorama found near this position');
+                } else if (data.code == 500) {
+                    alert('Server error');
+                } else if (data.code == 200) {
+                    this.panorama.setLocationAndPOV(data.location.latlng);
+                } else {
+                    alert('Unexpected problem');
+                }
+            }
+        };
+
+        this.streetviewclient.getNearestPanorama(clickedPosition,  callback.createDelegate(this));
     },
 
     onDblclick: function(evt) {



More information about the Commits mailing list