[Commits] r2069 - in sandbox/cmoullet/ux/RoutingPanel: examples ux/widgets

commits at geoext.org commits at geoext.org
Sat Apr 3 18:31:34 CEST 2010


Author: cmoullet
Date: 2010-04-03 18:31:34 +0200 (Sat, 03 Apr 2010)
New Revision: 2069

Modified:
   sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.html
   sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.js
   sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
Log:
Add OpenAddresses search in routingPanel

Modified: sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.html
===================================================================
--- sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.html	2010-04-02 05:40:24 UTC (rev 2068)
+++ sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.html	2010-04-03 16:31:34 UTC (rev 2069)
@@ -9,6 +9,8 @@
     <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
     <script type="text/javascript"
             src="http://svn.geoext.org/extensions/geoext.ux/ux/GeoNamesSearchCombo/lib/GeoExt.ux.geonames/GeoNamesSearchCombo.js"></script>
+    <script type="text/javascript"
+            src="http://svn.geoext.org/sandbox/cmoullet/ux/OpenAddressesSearchCombo/lib/GeoExt.ux.openaddresses/OpenAddressesSearchCombo.js"></script>
     <script type="text/javascript" src="../ux/widgets/RoutingPanel.js"></script>
     <script type="text/javascript" src="RoutingPanelExample.js"></script>
 </head>

Modified: sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.js
===================================================================
--- sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.js	2010-04-02 05:40:24 UTC (rev 2068)
+++ sandbox/cmoullet/ux/RoutingPanel/examples/RoutingPanelExample.js	2010-04-03 16:31:34 UTC (rev 2069)
@@ -4,6 +4,8 @@
 
 var routingPanel;
 
+var routingPanelOa;
+
 var viewport;
 
 var layer;
@@ -41,6 +43,10 @@
                     if (routingPanelItem) {
                         routingPanelItem.clearItinerary();
                     }
+                    var routingPanelItemOa = Ext.getCmp("routingPanelItemOa");
+                    if (routingPanelItemOa) {
+                        routingPanelItemOa.clearItinerary();
+                    }
                 }
             },
             {
@@ -77,15 +83,38 @@
                 width: 350,
                 items: [
                     {
+                        id: "routingpaneloa",
+                        title: "Routing Panel OpenAddresses",
+                        listeners: {
+                            'expand': function(panel) {
+                                this.doLayout();
+                            },
+                            'collapse': function(panel) {
+                                if (Ext.getCmp('routingPanelItemOa')) {
+                                    Ext.getCmp('routingPanelItemOa').clearItinerary();
+                                }
+                            }
+                        }
+                    },
+                    {
                         id: "routingpanel",
-                        title: "Routing Panel"
+                        title: "Routing Panel GeoNames",
+                        listeners: {
+                            'expand': function(panel) {
+                                this.doLayout();
+                            },
+                            'collapse': function(panel) {
+                                if (Ext.getCmp('routingPanelItem')) {
+                                    Ext.getCmp('routingPanelItem').clearItinerary();
+                                }
+                            }
+                        }
                     },
                     {
                         id: "treepanel",
                         title: "Layer Tree"
                     }
                 ]
-
             },
             {
                 region: "south",
@@ -107,6 +136,23 @@
         }),
         enableDD: true
     });
+    var routingPanelItemOa = {
+        xtype: 'gxux_routingpanel',
+        id: 'routingPanelItemOa',
+        map: map,
+        // Key for dev.geoext.org: 187a9f341f70406a8064d07a30e5695c
+        // Key for localhost: BC9A493B41014CAABB98F0471D759707
+        cloudmadeKey: '187a9f341f70406a8064d07a30e5695c',
+        geocodingType: 'openaddresses',
+        listeners:{
+            routingcomputed: function() {
+                //alert('Computation done');
+            },
+            beforeroutingcomputed: function() {
+                //alert('Before computation');
+            }
+        }
+    };
     var routingPanelItem = {
         xtype: 'gxux_routingpanel',
         id: 'routingPanelItem',
@@ -126,7 +172,10 @@
     };
     treePanel = Ext.getCmp("treepanel");
     treePanel.add(treePanelItem);
+    routingPanelOa = Ext.getCmp("routingpaneloa");
+    routingPanelOa.add(routingPanelItemOa);
     routingPanel = Ext.getCmp("routingpanel");
     routingPanel.add(routingPanelItem);
+    routingPanelOa.doLayout();
     routingPanel.doLayout();
 });
\ No newline at end of file

Modified: sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
===================================================================
--- sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js	2010-04-02 05:40:24 UTC (rev 2068)
+++ sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js	2010-04-03 16:31:34 UTC (rev 2069)
@@ -168,10 +168,10 @@
     cloudmadeKey: null,
 
     /** api: config[geocodingType]
-     *  Geocoding type. Per default: 'cloudmade'. Can be 'geonames'.
+     *  Geocoding type. Per default: 'cloudmade'. Can also be 'geonames' or 'openaddresses'.
      */
     /** private: property[geocodingType]
-     *  Geocoding type. Per default: 'cloudmade'. Can be 'geonames'.
+     *  Geocoding type. Per default: 'cloudmade'. Can also be 'geonames' or 'openaddresses'.
      */
     geocodingType: 'cloudmade',
 
@@ -375,6 +375,36 @@
             }, this);
         }
 
+        // Create openaddresses search combo
+        if (this.geocodingType == 'openaddresses') {
+            this.startLocationCombo = new GeoExt.ux.openaddresses.OpenAddressesSearchCombo({
+                fieldLabel: OpenLayers.i18n('A'),
+                map: this.map,
+                zoom: 18
+            });
+            this.startLocationCombo.on(
+                    "select", function(combo, record, index) {
+                if (this.routingStartFeature) {
+                    this.routingLayer.removeFeatures([this.routingStartFeature]);
+                }
+                this.startLocationCombo.locationString = record.data.geometry.coordinates[1] + ',' + record.data.geometry.coordinates[0];
+            }, this
+                    );
+
+
+            this.endLocationCombo = new GeoExt.ux.openaddresses.OpenAddressesSearchCombo({
+                fieldLabel: OpenLayers.i18n('B'),
+                map: this.map,
+                zoom: 18
+            });
+            this.endLocationCombo.on("select", function(combo, record, index) {
+                if (this.routingEndFeature) {
+                    this.routingLayer.removeFeatures([this.routingEndFeature]);
+                }
+                this.endLocationCombo.locationString = record.data.geometry.coordinates[1] + ',' + record.data.geometry.coordinates[0];
+            }, this);
+        }
+
         // Create routing result panel
         this.routingResultPanel = new Ext.Panel({
             border: false,



More information about the Commits mailing list