From 1da10942d535adf7d6e80a251856692459ba8360 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Sat, 21 Apr 2012 08:13:42 +0100 Subject: [PATCH] changed jsonp call, so that position of the callback command has to be given as "%jsonp" in the string --- WebContent/OSRM.Geocoder.js | 4 ++-- WebContent/OSRM.JSONP.js | 11 +++++------ WebContent/routing/OSRM.Routing.js | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 51eb4bc06..4790f734d 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -43,7 +43,7 @@ call: function(marker_id, query) { } //build request for geocoder - var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query; + var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json&json_callback=%jsonp" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query; OSRM.JSONP.call( call, OSRM.Geocoder._showResults, OSRM.Geocoder._showResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, {marker_id:marker_id,query:query} ); }, @@ -155,7 +155,7 @@ updateAddress: function(marker_id, do_fallback_to_lat_lng) { } else return; - var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&accept-language="+OSRM.Localization.current_language + "&lat=" + lat + "&lon=" + lng; + var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json&json_callback=%jsonp" + "&accept-language="+OSRM.Localization.current_language + "&lat=" + lat + "&lon=" + lng; OSRM.JSONP.call( call, OSRM.Geocoder._showReverseResults, OSRM.Geocoder._showReverseResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_"+marker_id, {marker_id:marker_id, do_fallback: do_fallback_to_lat_lng} ); }, diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index ba585700b..cd039987c 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -18,7 +18,6 @@ or see http://www.gnu.org/licenses/agpl.txt. // OSRM JSONP call wrapper // [wrapper for JSONP calls with DOM cleaning, fencing, timout handling] -xxx="test"; OSRM.JSONP = { // storage to keep track of unfinished JSONP calls @@ -67,15 +66,15 @@ OSRM.JSONP = { }; // clean DOM - //var jsonp = document.getElementById('jsonp_'+id); - //if(jsonp) - // jsonp.parentNode.removeChild(jsonp); + var jsonp = document.getElementById('jsonp_'+id); + if(jsonp) + jsonp.parentNode.removeChild(jsonp); // add script to DOM var script = document.createElement('script'); script.type = 'text/javascript'; - //script.id = 'jsonp_'+id; - script.src = source + "&json_callback=OSRM.JSONP.callbacks."+id + "&jsonp=console.log(xxx);OSRM.JSONP.callbacks."+id; + script.id = 'jsonp_'+id; + script.src = source.replace(/%jsonp/,"OSRM.JSONP.callbacks."+id); document.head.appendChild(script); // start timeout timer diff --git a/WebContent/routing/OSRM.Routing.js b/WebContent/routing/OSRM.Routing.js index 3032c1592..6eb77ed86 100644 --- a/WebContent/routing/OSRM.Routing.js +++ b/WebContent/routing/OSRM.Routing.js @@ -132,7 +132,7 @@ draggingTimeout: function() { _buildCall: function() { var source = OSRM.DEFAULTS.HOST_ROUTING_URL; - source += '?z=' + OSRM.G.map.getZoom() + '&output=json&geomformat=cmp'; + source += '?z=' + OSRM.G.map.getZoom() + '&output=json&jsonp=%jsonp&geomformat=cmp'; if(OSRM.G.markers.checksum) source += '&checksum=' + OSRM.G.markers.checksum; for(var i=0,size=OSRM.G.markers.route.length; i