[Commits] r1634 - in sandbox/cmoullet/ux/StreetViewPanel: examples tests/ux/widgets ux/control ux/widgets

commits at geoext.org commits at geoext.org
Wed Dec 30 07:22:22 CET 2009


Author: cmoullet
Date: 2009-12-30 07:22:22 +0100 (Wed, 30 Dec 2009)
New Revision: 1634

Modified:
   sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js
   sandbox/cmoullet/ux/StreetViewPanel/tests/ux/widgets/StreetViewPanel.html
   sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js
   sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Document code
Add unit tests

Modified: sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js	2009-12-30 04:57:40 UTC (rev 1633)
+++ sandbox/cmoullet/ux/StreetViewPanel/examples/StreetViewPanelExample.js	2009-12-30 06:22:22 UTC (rev 1634)
@@ -70,13 +70,18 @@
             }
         ]});
 
+    var positionPano = new OpenLayers.LonLat(739019.93169167, 5861792.5629019);
+    positionPano.transform(map.projection, new OpenLayers.Projection("EPSG:4326"));
+    var featurePosition = new GLatLng(positionPano.lat, positionPano.lon);
+
     var streetViewPanelItem = {
         xtype: 'gxux_streetviewpanel',
         id: 'streetViewPanelItem',
         map: map,
         videoMode: true,
         showLinks: true,
-        showTool: true
+        showTool: true,
+        panoramaLocation: featurePosition
     };
 
     viewport = new Ext.Viewport({

Modified: sandbox/cmoullet/ux/StreetViewPanel/tests/ux/widgets/StreetViewPanel.html
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/tests/ux/widgets/StreetViewPanel.html	2009-12-30 04:57:40 UTC (rev 1633)
+++ sandbox/cmoullet/ux/StreetViewPanel/tests/ux/widgets/StreetViewPanel.html	2009-12-30 06:22:22 UTC (rev 1634)
@@ -18,28 +18,51 @@
     <script type="text/javascript" src="../../../ux/control/StreetViewClick.js"></script>
     <script type="text/javascript">
         function test_ctor(t) {
-            t.plan(2);
 
-            // set up
+            t.plan(5);
 
-            var c, map = {};
+            var options = {
+                projection: new OpenLayers.Projection("EPSG:900913"),
+                units: "m",
+                numZoomLevels: 18,
+                maxResolution: 156543.0339,
+                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
+                        20037508, 20037508.34)
+            };
 
-            map = new OpenLayers.Map();
+            var layer = new OpenLayers.Layer.Google(
+                    "Google Street", {sphericalMercator: true});
 
-            // test
+            var map = new OpenLayers.Map('map', options);
+            map.addLayer(layer);
+            var extent = new OpenLayers.Bounds(736500, 5861500, 740700, 5862500);
+            map.zoomToExtent(extent);
 
-            c = new GeoExt.ux.StreetViewPanel({
+            var positionPano = new OpenLayers.LonLat(739019.93169167, 5861792.5629019);
+            positionPano.transform(map.projection, new OpenLayers.Projection("EPSG:4326"));
+            var featurePosition = new GLatLng(positionPano.lat, positionPano.lon);
+
+            var streetViewPanel = new GeoExt.ux.StreetViewPanel({
                 renderTo: "StreetViewPanel",
-                map: map
+                map: map,
+                panoramaLocation: featurePosition
             });
-            t.ok(c instanceof GeoExt.ux.StreetViewPanel,
+            t.ok(streetViewPanel instanceof GeoExt.ux.StreetViewPanel,
                     "ctor creates a GeoExt.ux.StreetViewPanel object");
-            t.ok(c instanceof Ext.Panel,
+            t.ok(streetViewPanel instanceof Ext.Panel,
                     "ctor creates an Ext.Panel object");
-            c.destroy();
+
+            t.eq(map.getCenter().toString(), "lon=738600,lat=5862000", "map center set correctly");
+            t.eq(streetViewPanel.videoTimeInterval, 2500, "video time intervall is 2500 per default");
+
+            t.delay_call(3, function() {
+                t.eq(streetViewPanel.panorama.getLatLng().lat(), 46.505891, "panorama correctly located");
+                streetViewPanel.destroy();
+            });
         }
     </script>
 <body>
+<div id="map"></div>
 <div id="StreetViewPanel"></div>
 </body>
 </html>

Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js	2009-12-30 04:57:40 UTC (rev 1633)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/control/StreetViewClick.js	2009-12-30 06:22:22 UTC (rev 1634)
@@ -6,9 +6,24 @@
  * of the license.
  */
 
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = StreetViewClick
+ */
+
 Ext.namespace('GeoExt.ux');
 
+/** api: constructor
+ *  .. class:: StreetViewClick(options)
+ *
+ *      Create a click control
+ *      Extends ``OpenLayers.Control``
+ */
 GeoExt.ux.StreetViewClick = OpenLayers.Class(OpenLayers.Control, {
+
+    /** api: property[defaultHandlerOptions]
+     *  Default options.
+     */
     defaultHandlerOptions: {
         'single': true,
         'double': false,
@@ -17,6 +32,9 @@
         'stopDouble': false
     },
 
+    /** private: method[initialize]
+     *  Initializes the control
+     */
     initialize: function(options) {
         this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
         OpenLayers.Control.prototype.initialize.apply(this, arguments);
@@ -27,7 +45,9 @@
                 );
     },
 
-
+    /** private: method[onClick]
+     *  Update the Street View Panorama according to the clicked position
+     */
     onClick: function(evt) {
         var lonlat = this.map.getLonLatFromViewPortPx(evt.xy);
         lonlat.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
@@ -35,6 +55,9 @@
         this.streetviewclient.getNearestPanorama(clickedPosition, this.panorama.callback.createDelegate(this));
     },
 
+    /** private: method[onDblclick]
+     *  Not implemented
+     */
     onDblclick: function(evt) {
         alert('doubleClick');
     }

Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-12-30 04:57:40 UTC (rev 1633)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js	2009-12-30 06:22:22 UTC (rev 1634)
@@ -6,9 +6,15 @@
  * of the license.
  */
 
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = StreetViewPanel
+ *  base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Panel>`_
+ */
 Ext.namespace('GeoExt.ux');
 
 GeoExt.ux.StreetViewPanel = Ext.extend(Ext.Panel, {
+
     /** api: config[map]
      *  ``OpenLayers.Map``  A configured map
      */
@@ -17,19 +23,13 @@
      */
     map: null,
 
-    /** api: config[panorama]
-     *  ``GStreetviewPanorama``  A GStreetviewPanorama object holds an instance of the Flash® Street View Panorama viewer.
-     */
     /** private: property[panorama]
-     *  ``GStreetviewPanorama``  The panorama object.
+     *  ``GStreetviewPanorama``  The panorama object. A GStreetviewPanorama object holds an instance of the Flash® Street View Panorama viewer.
      */
     panorama: null,
 
-    /** api: config[streetviewclient]
-     *  ``GStreetviewClient``  A GStreetviewClient object performs searches for Street View data based on parameters that are passed to its methods.
-     */
     /** private: property[streetviewclient]
-     *  ``GStreetviewClient``  The Street View Client object.
+     *  ``GStreetviewClient``  The Street View Client object. A GStreetviewClient object performs searches for Street View data based on parameters that are passed to its methods.
      */
     streetviewclient: null,
 
@@ -45,12 +45,12 @@
      *  ``Boolean``  Defines if the video mode is activated.
      */
     /** private: property[videoMode]
-     *  ``Boolean``  videoMode
+     *  ``Boolean``  Is video mode active ?
      */
     videoMode: true,
 
     /** api: config[videoTimeInterval]
-     *  ``Boolean``  Defines the time in millisecond between the move
+     *  ``Boolean``  Defines the time in millisecond between the move during video mode.
      */
     /** private: property[videoTimeInterval]
      *  ``Boolean``  videoInterval
@@ -66,7 +66,7 @@
     showTool: true,
 
     /** api: config[showLinks]
-     *  ``Boolean``  Defines if the links are represented in the map
+     *  ``Boolean``  Defines if the panorama links are represented in the map
      */
     /** private: property[showLinks]
      *  ``Boolean``  Are link(s) visible ?
@@ -111,11 +111,12 @@
     /** private: property[readPermalink]
      *  ``Boolean``  Read the permalink in the url if presents
      */
-
     readPermalink: true,
 
+    /** private: method[initComponent]
+     *  Private initComponent override.
+     */
     initComponent : function() {
-
         var defConfig = {
             plain: true,
             border: false
@@ -126,13 +127,17 @@
         GeoExt.ux.StreetViewPanel.superclass.initComponent.call(this);
     },
 
-    // afterRender contains the tools for the management of the interaction between the map and the panorama
+    /** private: method[afterRender]
+     *  Private afterRender override.
+     *  Creates a Street View Panorame Instance See: http://code.google.com/intl/fr/apis/maps/documentation/reference.html#GStreetviewPanorama
+     *  This methods add functions to the Street View Panorama (this.panorama):
+     *  - getPermalink(complete): get the permalink parameters
+     */
     afterRender : function() {
         if (this.ownerCt) {
             var wh = this.ownerCt.getSize();
             Ext.applyIf(this, wh);
         }
-        //alert(G_API_VERSION);
         GeoExt.ux.StreetViewPanel.superclass.afterRender.call(this);
 
         // Create StreetViewClient for querying information about panorama
@@ -291,7 +296,6 @@
             }
         });
 
-
         // Callback to manage panorama when used with getNearestPanorama
         this.panorama.callback = function (data) {
             this.deleteFeatures = function() {
@@ -543,6 +547,10 @@
         }
     },
 
+    /** private: method[beforeDestroy]
+     *  Destroy Street View Panorama instance and navigation tools
+     *
+     */
     beforeDestroy: function() {
         if (this.clickMode) {
             if (this.map) {
@@ -571,6 +579,10 @@
         GeoExt.ux.StreetViewPanel.superclass.beforeDestroy.apply(this, arguments);
     },
 
+    /** private: method[onResize]
+     *  Resize Street View Panorama
+     *
+     */
     onResize : function(w, h) {
         GeoExt.ux.StreetViewPanel.superclass.onResize.call(this, w, h);
         if (this.panorama) {
@@ -580,6 +592,10 @@
         }
     },
 
+    /** private: method[setSize]
+     *  Set size of Street View Panorama
+     *
+     */
     setSize : function(width, height, animate) {
         GeoExt.ux.StreetViewPanel.superclass.setSize.call(this, width, height, animate);
         if (this.panorama) {



More information about the Commits mailing list