From fe6d854e11de128b2b53572792059b0f6d9d07bf Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Sun, 18 Mar 2012 17:42:05 +0100 Subject: [PATCH] improved handling of dragging, link to route gui improved, JSONP can now take parameters --- WebContent/OSRM.JSONP.js | 6 +++--- WebContent/OSRM.Localization.js | 6 ++++-- WebContent/OSRM.Markers.js | 31 ++++++++++--------------------- WebContent/geocoder.js | 4 ++-- WebContent/routing.js | 30 +++++++++++++----------------- 5 files changed, 32 insertions(+), 45 deletions(-) diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index 00954e083..3a337bd57 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -34,7 +34,7 @@ OSRM.JSONP = { // init JSONP call - call: function(source, callback_function, timeout_function, timeout, id) { + call: function(source, callback_function, timeout_function, timeout, id, parameters) { // only one active JSONP call per id if (OSRM.JSONP.fences[id] == true) return false; @@ -43,7 +43,7 @@ OSRM.JSONP = { // wrap timeout function OSRM.JSONP.timeouts[id] = function(response) { try { - timeout_function(response); + timeout_function(response, parameters); } finally { OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty; @@ -59,7 +59,7 @@ OSRM.JSONP = { OSRM.JSONP.timers[id] = undefined; try { - callback_function(response); // actual wrapped callback + callback_function(response, parameters); // actual wrapped callback } finally { OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions OSRM.JSONP.timeouts[id] = OSRM.JSONP.late; diff --git a/WebContent/OSRM.Localization.js b/WebContent/OSRM.Localization.js index 52cb267be..652f868cf 100644 --- a/WebContent/OSRM.Localization.js +++ b/WebContent/OSRM.Localization.js @@ -57,7 +57,8 @@ OSRM.Localization["de"] = { "NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel", // routing "ROUTE_DESCRIPTION": "Routenbeschreibung", -"GET_LINK": "Generiere Link", +"GET_LINK_TO_ROUTE": "Generiere Link", +"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort", "LINK_TO_ROUTE_TIMEOUT": "nicht möglich", "GPX_FILE": "GPX Datei", "DISTANCE": "Distanz", @@ -97,7 +98,8 @@ OSRM.Localization["en"] = { "NO_RESULTS_FOUND_TARGET": "No results found for end", //routing "ROUTE_DESCRIPTION": "Route Description", -"GET_LINK": "Generate Link", +"GET_LINK_TO_ROUTE": "Generate Link", +"GENERATE_LINK_TO_ROUTE": "waiting for link", "LINK_TO_ROUTE_TIMEOUT": "not available", "GPX_FILE": "GPX File", "DISTANCE": "Distance", diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index 4754ab78d..b1f117ae0 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -30,7 +30,7 @@ OSRM.Marker = function( label, style, position ) { this.dirty_type = true; this.shown = false; - this.hint = undefined; + this.hint = null; }; OSRM.extend( OSRM.Marker,{ show: function() { @@ -44,7 +44,7 @@ hide: function() { setPosition: function( position ) { this.position = position; this.marker.setLatLng( position ); - this.hint = undefined; + this.hint = null; }, getPosition: function() { return this.position; @@ -113,19 +113,15 @@ onClick: function(e) { OSRM.G.markers.highlight.hide(); }, onDrag: function(e) { - this.parent.dirty_move = true; this.parent.setPosition( e.target.getLatLng() ); - if(OSRM.G.dragging == true) // TODO: hack that deals with drag events after dragend event - getRoute(OSRM.C.NO_DESCRIPTION); - else - getRoute(OSRM.C.FULL_DESCRIPTION); - + getRoute(OSRM.C.NO_DESCRIPTION); updateLocation( this.parent.label ); }, onDragStart: function(e) { OSRM.G.dragging = true; + this.parent.dirty_move = true; - // hack to store id of dragged marker + // store id of dragged marker for( var i=0; i'+response.ShortURL+']'; @@ -141,10 +142,10 @@ function showRouteDescription(response) { query_string += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng(); // create link to the route - var route_link ='['+OSRM.loc("GET_LINK")+']'; + var route_link ='['+OSRM.loc("GET_LINK_TO_ROUTE")+']'; // create GPX link - var gpx_link = '['+OSRM.loc("GPX_FILE")+']'; + var gpx_link = '['+OSRM.loc("GPX_FILE")+']'; // create route description var route_desc = ""; @@ -280,9 +281,9 @@ function getRoute(do_description) { } // prepare JSONP call - var type = undefined; - var callback = undefined; - var timeout = undefined; + var type = null; + var callback = null; + var timeout = null; var source = OSRM.DEFAULTS.HOST_ROUTING_URL; source += '?z=' + OSRM.G.map.getZoom() + '&output=json' + '&geomformat=cmp'; @@ -327,7 +328,7 @@ function getRoute(do_description) { // } } function timeoutDrag() { - OSRM.G.markers.route[OSRM.G.dragid].hint = undefined; + OSRM.G.markers.route[OSRM.G.dragid].hint = null; getRoute(OSRM.C.NO_DESCRIPTION); } @@ -378,13 +379,8 @@ function snapRoute() { for(var i=0; i