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

commits at geoext.org commits at geoext.org
Thu Nov 26 08:01:53 CET 2009


Author: cmoullet
Date: 2009-11-26 08:01:53 +0100 (Thu, 26 Nov 2009)
New Revision: 1500

Modified:
   sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
   sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Add 2DNavigationTool


Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js	2009-11-26 05:05:03 UTC (rev 1499)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js	2009-11-26 07:01:53 UTC (rev 1500)
@@ -22,18 +22,34 @@
         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) {
+
         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);
+
+        // Navigation tool
+        this.drawNavigationTool = function(layer, position, yaw, links) {
+            layer.destroyFeatures();
+            var circlePosition = new OpenLayers.Geometry.Point(position.lng(), position.lat());
+            circlePosition.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
+            this.panorama.navigationToolStyle = {
+                externalGraphic: "../resources/tool.png",
+                pointRadius: 30,
+                rotation: this.yaw
+            };
+            this.panorama.navigationTool = new OpenLayers.Feature.Vector(circlePosition, null, this.panorama.navigationToolStyle);
+            // Draw the yaw direction
+            layer.addFeatures([this.panorama.navigationTool]);
+        };
         var callback = function (data) {
             if (data) {
                 if (data.code == 600) {
@@ -43,13 +59,23 @@
                 } else if (data.code == 200) {
                     var POV = {yaw: this.yaw,  pitch: this.pitch, zoom: this.zoom};
                     this.panorama.setLocationAndPOV(data.location.latlng, POV);
+                    // Add the navigation tool
+                    this.drawNavigationTool(this.navigationToolLayer, data.location.latlng, this.yaw, data.links)
                 } else {
                     alert(OpenLayers.i18n('Google Street View: Unexpected problem'));
                 }
             }
         };
+        GEvent.addListener(this.panorama, "yawchanged", function(yaw) {
+             this.navigationToolStyle.rotation = yaw;
+             this.navigationTool.layer.drawFeature(this.navigationTool);
+        });
+        GEvent.addListener(this.panorama, "flashresponse", function(yaw) {
+             //TODO move the 2Dtool
+        });
+        this.streetviewclient.getNearestPanorama(clickedPosition, callback.createDelegate(this));
 
-        this.streetviewclient.getNearestPanorama(clickedPosition,  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 05:05:03 UTC (rev 1499)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-11-26 07:01:53 UTC (rev 1500)
@@ -42,13 +42,13 @@
      */
     clickMode: true,
 
-    /** api: config[toolMode]
+    /** api: config[showTool]
      *  ``Boolean``  Defines if the 2D tool is shown in the map
      */
-    /** private: property[toolMode]
+    /** private: property[showTool]
      *  ``Boolean``  Is tool visible ?
      */
-    toolMode: true,
+    showTool: true,
 
     /** api: config[yaw]
      *  ``Number``  The camera yaw in degrees relative to true north. True north is 0 degrees, east is 90 degrees, south is 180 degrees, west is 270 degrees.
@@ -98,6 +98,10 @@
         this.streetviewclient = new GStreetviewClient();
         if (this.map) {
             if (this.clickMode) {
+                if (this.showTool) {
+                    this.navigationToolLayer = new OpenLayers.Layer.Vector("2DNavigationTool");
+                    this.map.addLayer(this.navigationToolLayer);
+                }
                 this.clickControl = new GeoExt.ux.Click({
                     handlerOptions: {
                         "single": true
@@ -106,7 +110,8 @@
                     streetviewclient: this.streetviewclient,
                     yaw: this.yaw,
                     pitch: this.pitch,
-                    level: this.level 
+                    level: this.level,
+                    navigationToolLayer: this.navigationToolLayer
                 });
                 this.map.addControl(this.clickControl);
                 this.clickControl.activate();
@@ -119,6 +124,10 @@
             if (this.map) {
                 this.clickControl.deactivate();
                 this.map.removeControl(this.clickControl);
+                if (this.showTool) {
+                    this.map.removeLayer(this.navigationToolLayer);
+                    this.navigationToolLayer.destroy();
+                }
             }
         }
         this.panorama.remove();



More information about the Commits mailing list