[Commits] r1567 - in sandbox/cmoullet/ux/StreetViewPanel: examples ux/widgets

commits at geoext.org commits at geoext.org
Mon Dec 7 23:47:39 CET 2009


Author: cmoullet
Date: 2009-12-07 23:47:39 +0100 (Mon, 07 Dec 2009)
New Revision: 1567

Modified:
   sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.html
   sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js
   sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:


Modified: sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.html
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.html	2009-12-07 17:52:42 UTC (rev 1566)
+++ sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.html	2009-12-07 22:47:39 UTC (rev 1567)
@@ -2,14 +2,15 @@
 <head>
     <title>GeoExt StreetView Panel UX Example</title>
     <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
-    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
-    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
+    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css"/>
+    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css"/>
     <!-- Google Maps API for "localhost" -->
     <!--
     <script src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
     -->
 
     <!-- Google Maps API for "dev.geoext.org" -->
+    <!-- -->
     <script src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA'></script>
 
     <script src="http://openlayers.org/api/2.8/OpenLayers.js"></script>

Modified: sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js	2009-12-07 17:52:42 UTC (rev 1566)
+++ sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js	2009-12-07 22:47:39 UTC (rev 1567)
@@ -63,7 +63,7 @@
                 handler: function() {
                     var streetViewPanelItem = Ext.getCmp("streetViewPanelItem");
                     if (streetViewPanelItem) {
-                       window.open(streetViewPanelItem.panorama.getPermalink(true));
+                        window.open(streetViewPanelItem.panorama.getPermalink(true));
                     }
 
                 }
@@ -120,8 +120,4 @@
     streetViewPanel.add(streetViewPanelItem);
     streetViewPanel.doLayout();
     viewport.doLayout();
-
-    var parameters = OpenLayers.Util.getParameters();
-    var streetViewPanelItemObj = Ext.getCmp("streetViewPanelItem");
-    streetViewPanelItemObj.setPermalink(parameters);
 });
\ No newline at end of file

Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-12-07 17:52:42 UTC (rev 1566)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-12-07 22:47:39 UTC (rev 1567)
@@ -105,6 +105,15 @@
      */
     panoramaLocation: null,
 
+    /** api: config[readPermalink]
+     *  ``Boolean``  Read the permalink in the url if presents
+     */
+    /** private: property[readPermalink]
+     *  ``Boolean``  Read the permalink in the url if presents
+     */
+
+    readPermalink: true,
+
     initComponent : function() {
 
         var defConfig = {
@@ -143,6 +152,7 @@
         this.panorama.videoPlay = false;
         this.panorama.videoReady = true;
         this.panorama.videoTimeInterval = this.videoTimeInterval;
+        this.panorama.panoramaLocation = this.panoramaLocation;
         this.panorama.transitionYaw = null;
 
         // Draw navigation tool in map
@@ -188,6 +198,62 @@
             return permalink;
         };
 
+        // String to boolean function
+        this.panorama.stringToBoolean = function(string) {
+            switch (string.toLowerCase()) {
+                case "true": case "yes": case "1": return true;
+                case "false": case "no": case "0": case null: return false;
+                default: return Boolean(string);
+            }
+        };
+
+        this.panorama.setPermalink = function(parameters) {
+            if (parameters.easting && parameters.northing) {
+                var position = new OpenLayers.LonLat(parseFloat(parameters.easting), parseFloat(parameters.northing));
+                if (this.map) {
+                    this.map.setCenter(position);
+                }
+            }
+            if (parameters.zoom) {
+                if (this.map) {
+                    this.map.zoomTo(parseInt(parameters.zoom, 10));
+                }
+            }
+            if (parameters.yaw) {
+                this.yaw = parseFloat(parameters.yaw);
+            }
+            if (parameters.pitch) {
+                this.pitch = parseFloat(parameters.pitch);
+            }
+            if (parameters.panoZoom) {
+                this.zoom = parseInt(parameters.panoZoom, 10);
+            }
+            if (parameters.clickMode) {
+                this.clickMode = this.stringToBoolean(parameters.clickMode);
+            }
+            if (parameters.videoTimeInterval) {
+                this.videoTimeInterval = parseFloat(parameters.videoTimeInterval);
+            }
+            if (parameters.showTool) {
+                this.showTool = this.stringToBoolean(parameters.showTool);
+            }
+            if (parameters.showLinks) {
+                this.showLinks = this.stringToBoolean(parameters.showLinks);
+            }
+            if (parameters.panoEasting && parameters.panoNorthing) {
+                var positionPano = new OpenLayers.LonLat(parseFloat(parameters.panoEasting), parseFloat(parameters.panoNorthing));
+                positionPano.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
+                var featurePosition = new GLatLng(positionPano.lat, positionPano.lon);
+                this.panoramaLocation = featurePosition;
+            }
+        };
+
+        // Set the permalink
+        if (this.readPermalink) {
+            var parameters = OpenLayers.Util.getParameters();
+            this.panorama.setPermalink(parameters);
+        }
+
         // Draw link in map
         this.panorama.drawLinkTool = function(panorama, position, links) {
             // Destroy the existing features
@@ -219,7 +285,10 @@
             this.zoom = zoom;
         });
         GEvent.addListener(this.panorama, "initialized", function(gstreetviewlocation) {
-            this.streetviewclient.getPanoramaById(gstreetviewlocation.panoId, this.callbackDrawTools.createDelegate(this));
+            if (!this.videoPlay) {
+                //console.log('listener initialized');
+                this.streetviewclient.getPanoramaById(gstreetviewlocation.panoId, this.callbackDrawTools.createDelegate(this));
+            }
         });
 
 
@@ -355,8 +424,9 @@
         };
 
         // Set initial position of panorama
-        if (this.panoramaLocation) {
-            this.streetviewclient.getNearestPanorama(this.panoramaLocation, this.callback.createDelegate(this));
+        if (this.panorama.panoramaLocation) {
+            //console.log('panorama location init');
+            this.streetviewclient.getNearestPanorama(this.panorama.panoramaLocation, this.panorama.callback.createDelegate(this));
         }
 
         // Add features associated to map
@@ -393,6 +463,8 @@
                         var position = this.panorama.map.getLonLatFromPixel(pixel);
                         position.transform(this.panorama.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
                         var featurePosition = new GLatLng(position.lat, position.lon);
+
+                        //console.log('dragging feature');
                         this.streetviewclient.getNearestPanorama(featurePosition, this.panorama.callback.createDelegate(this));
                     },
                     moveFeature: function(pixel) {
@@ -437,6 +509,7 @@
                                 this.panorama.transitionYaw = feature.attributes.angle;
                                 //console.log("PlayVideo: previousYawVideo: "+ this.panorama.previousYawVideo);
                                 if (this.panorama.videoReady) {
+                                    //console.log('play video: mode auto');
                                     this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
                                     this.panorama.videoReady = false;
                                 }
@@ -444,17 +517,18 @@
                             // Manage the start and stop of the video
                             if (!this.panorama.videoPlay) {
                                 //console.log("Start Play Video");
+                                this.panorama.videoPlay = true;
                                 this.panorama.videoInterval = setInterval(this.playVideo.createDelegate(this), this.panorama.videoTimeInterval);
                                 this.playVideo();
-                                this.panorama.videoPlay = true;
                             } else {
                                 //console.log("Stop Play Video");
-                                this.panorama.videoPlay = false;
                                 this.panorama.nextFeature = null;
                                 this.panorama.transitionYaw = null;
                                 clearInterval(this.panorama.videoInterval);
+                                this.panorama.videoPlay = false;
                             }
                         } else {
+                            //console.log('play video: mode manuel');
                             this.panorama.transitionYaw = feature.attributes.angle;
                             this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
                         }
@@ -469,45 +543,6 @@
         }
     },
 
-    // Set the permalink
-    setPermalink: function(parameters) {
-        if (parameters.yaw) {
-            if (parameters.easting && parameters.northing) {
-                var position = new OpenLayers.LonLat(parseFloat(parameters.easting), parseFloat(parameters.northing));
-                if (this.map) {
-                    this.map.setCenter(position);
-                }
-            }
-            if (parameters.zoom) {
-                if (this.map) {
-                    this.map.zoomTo(parseInt(parameters.zoom,10));
-                }
-            }
-            this.panorama.yaw = parseFloat(parameters.yaw);
-            this.panorama.pitch = parseFloat(parameters.pitch);
-            this.panorama.zoom = parseInt(parameters.panoZoom, 10);
-            this.panorama.clickMode = this.stringToBoolean(parameters.clickMode);
-            this.panorama.videoTimeInterval = parseFloat(parameters.videoTimeInterval);
-            this.panorama.showTool = this.stringToBoolean(parameters.showTool);
-            this.panorama.showLinks = this.stringToBoolean(parameters.showLinks);
-            if (parameters.panoEasting && parameters.panoNorthing) {
-                var positionPano = new OpenLayers.LonLat(parseFloat(parameters.panoEasting), parseFloat(parameters.panoNorthing));
-                positionPano.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
-                var featurePosition = new GLatLng(positionPano.lat, positionPano.lon);
-                this.streetviewclient.getNearestPanorama(featurePosition, this.panorama.callback.createDelegate(this));
-            }
-        }
-        return;
-    },
-
-    stringToBoolean: function(string) {
-        switch (string.toLowerCase()) {
-            case "true": case "yes": case "1": return true;
-            case "false": case "no": case "0": case null: return false;
-            default: return Boolean(string);
-        }
-    },
-
     beforeDestroy: function() {
         if (this.clickMode) {
             if (this.map) {



More information about the Commits mailing list