[Commits] r1744 - sandbox/cmoullet/ux/RoutingPanel/ux/widgets
commits at geoext.org
commits at geoext.org
Thu Jan 14 05:38:03 CET 2010
Author: cmoullet
Date: 2010-01-14 05:38:00 +0100 (Thu, 14 Jan 2010)
New Revision: 1744
Modified:
sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
Log:
Permalink support
Modified: sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
===================================================================
--- sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js 2010-01-14 00:25:57 UTC (rev 1743)
+++ sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js 2010-01-14 04:38:00 UTC (rev 1744)
@@ -509,13 +509,16 @@
*/
'beforeroutingcomputed');
+
GeoExt.ux.RoutingPanel.superclass.initComponent.call(this);
},
/** private: method[afterRender]
* Private afterRender override.
*/
- afterRender : function() {
+ afterRender: function() {
+ GeoExt.ux.RoutingPanel.superclass.afterRender.call(this);
+
// Create empty proxy
this.proxy = new Ext.data.ScriptTagProxy({
url: 'to_be_replaced',
@@ -526,7 +529,9 @@
'beforeload', function() {
this.fireEvent('beforeroutingcomputed', this);
this.routingResultPanel.html = OpenLayers.i18n('Computation ongoing....');
- this.routingResultPanel.body.update(this.routingResultPanel.html);
+ if (this.routingResultPanel.body) {
+ this.routingResultPanel.body.update(this.routingResultPanel.html);
+ }
var newUrl = this.startLocationCombo.locationString + ',' + this.endLocationCombo.locationString;
newUrl = newUrl + "/" + this.route_typeCloudmade + ".js?lang=" + this.lang;
this.proxy.url = "http://routes.cloudmade.com/" + this.cloudmadeKey + "/api/0.3/" + newUrl;
@@ -575,9 +580,9 @@
if (this.readPermalink) {
var parameters = OpenLayers.Util.getParameters();
this.setPermalink(parameters);
-
}
- },
+ }
+ ,
/** method[getPermalink]
* Create the permalink
@@ -597,19 +602,35 @@
permalink = '';
}
+ permalink = permalink + "routingReadPermalink=" + this.readPermalink;
+ permalink = permalink + "&routingRecenterMap=" + this.routingRecenterMap;
+
if (this.startLocationCombo.locationString && this.routingPathFeature) {
- permalink = permalink + "routingStartLocationString=" + this.startLocationCombo.locationString;
+ permalink = permalink + "&routingStartLocationString=" + this.startLocationCombo.locationString;
}
if (this.endLocationCombo.locationString && this.routingPathFeature) {
permalink = permalink + "&routingEndLocationString=" + this.endLocationCombo.locationString;
}
- if (this.map) {
+ if (this.startLocationCombo.value) {
+ permalink = permalink + "&routingStartLocationValue=" + this.startLocationCombo.value;
+ }
+ if (this.endLocationCombo.value) {
+ permalink = permalink + "&routingEndLocationValue=" + this.endLocationCombo.value;
+ }
+ if (this.startLocationCombo.emptyText.indexOf(OpenLayers.i18n('Position: ')) > -1) {
+ permalink = permalink + "&routingStartLocationEmptyText=" + this.startLocationCombo.emptyText;
+ }
+ if (this.endLocationCombo.emptyText.indexOf(OpenLayers.i18n('Position: ')) > -1) {
+ permalink = permalink + "&routingEndLocationEmptyText=" + this.endLocationCombo.emptyText;
+ }
+ if (this.map && !this.routingRecenterMap) {
permalink = permalink + "&routingeasting=" + this.map.getCenter().lon;
permalink = permalink + "&routingnorthing=" + this.map.getCenter().lat;
permalink = permalink + "&routingzoom=" + this.map.getZoom();
}
return permalink;
- },
+ }
+ ,
/** private: method[setPermalink]
* Set the permalink according to the url parameters
@@ -617,6 +638,12 @@
* :param parameters URL paramaters
*/
setPermalink: function(parameters) {
+ if (parameters.routingReadPermalink) {
+ this.readPermalink = this.stringToBoolean(parameters.routingReadPermalink);
+ }
+ if (parameters.routingRecenterMap) {
+ this.routingRecenterMap = this.stringToBoolean(parameters.routingRecenterMap);
+ }
if (parameters.routingStartLocationString) {
this.startLocationCombo.locationString = parameters.routingStartLocationString[0] + "," + parameters.routingStartLocationString[1];
}
@@ -624,8 +651,7 @@
this.endLocationCombo.locationString = parameters.routingEndLocationString[0] + "," + parameters.routingEndLocationString[1];
}
if (parameters.routingStartLocationString && parameters.routingEndLocationString) {
- // TODO: supporte itinerary computation
- //this.getItinerary();
+ this.getItinerary();
}
if (parameters.routingeasting && parameters.routingnorthing) {
var position = new OpenLayers.LonLat(parseFloat(parameters.routingeasting), parseFloat(parameters.routingnorthing));
@@ -638,8 +664,33 @@
this.map.zoomTo(parseInt(parameters.routingzoom, 10));
}
}
+ if (parameters.routingStartLocationValue) {
+ this.startLocationCombo.setValue(parameters.routingStartLocationValue);
+ }
+ if (parameters.routingEndLocationValue) {
+ this.endLocationCombo.setValue(parameters.routingEndLocationValue);
+ }
+ if (parameters.routingStartLocationEmptyText) {
+ this.startLocationCombo.emptyText = parameters.routingStartLocationEmptyText.toString();
+ }
+ if (parameters.routingEndLocationEmptyText) {
+ this.endLocationCombo.emptyText = parameters.routingEndLocationEmptyText.toString();
+ }
},
+ /** private: method[stringToBoolean]
+ * Transform a string (true, false, yes, no 1 or 0) to a boolean
+ *
+ * :param string
+ */
+ 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);
+ }
+ },
+
/** private: method[getItinerary]
* Compute the itinerary and assign the results
*/
@@ -683,8 +734,7 @@
this.routingResultPanel.body.update(this.routingResultPanel.html);
}
this.fireEvent('routingcomputed', this);
- }, this
- );
+ }, this);
this.routingStore.load();
} else {
alert('Routing service: ' + this.routingServiceType + ' not supported. Patch welcome !');
More information about the Commits
mailing list