diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index 76948f3a4..0ea26885f 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -59,7 +59,16 @@ isShown: function() { centerView: function(zoom) { if( zoom == undefined ) zoom = OSRM.DEFAULTS.ZOOM_LEVEL; - OSRM.G.map.setView( new L.LatLng( this.position.lat, this.position.lng), zoom); + + var position; + if( document.getElementById('main-wrapper').style.left != "-410px" ) { + var point = OSRM.G.map.project( this.position, zoom); + point.x-=200; + position = OSRM.G.map.unproject(point,zoom); + } else { + position = this.position; + } + OSRM.G.map.setView( position, zoom); }, toString: function() { return "OSRM.Marker: \""+this.label+"\", "+this.position+")"; diff --git a/WebContent/OSRM.Route.js b/WebContent/OSRM.Route.js index 39cb278af..d76af161e 100644 --- a/WebContent/OSRM.Route.js +++ b/WebContent/OSRM.Route.js @@ -53,7 +53,22 @@ setStyle: function(style) { }, centerView: function() { var bounds = new L.LatLngBounds( this.getPositions() ); - OSRM.G.map.fitBounds( bounds ); + + if( document.getElementById('main-wrapper').style.left != "-410px" ) { + var southwest = bounds.getSouthWest(); + var northeast = bounds.getNorthEast(); + var zoom = OSRM.G.map.getBoundsZoom(bounds); + var sw_point = OSRM.G.map.project( southwest, zoom); + sw_point.x-=410; + sw_point.y+=10; + var ne_point = OSRM.G.map.project( northeast, zoom); + ne_point.y-=10; + sw_point.x+=10; + bounds.extend( OSRM.G.map.unproject(sw_point,zoom) ); + bounds.extend( OSRM.G.map.unproject(ne_point,zoom) ); + + OSRM.G.map.fitBounds( bounds ); + } }, onClick: function(e) { if(OSRM.G.route.isRoute()) diff --git a/WebContent/geocoder.js b/WebContent/geocoder.js index f2122d18f..653387d29 100644 --- a/WebContent/geocoder.js +++ b/WebContent/geocoder.js @@ -43,7 +43,7 @@ function callGeocoder(marker_id, query) { //build request for geocoder var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query; - OSRM.JSONP.call( call, showGeocoderResults, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, marker_id ); + OSRM.JSONP.call( call, showGeocoderResults, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, {marker_id:marker_id,query:query} ); } @@ -64,14 +64,14 @@ function onclickGeocoderResult(marker_id, lat, lon) { // process geocoder response -function showGeocoderResults(response, marker_id) { +function showGeocoderResults(response, parameters) { if(!response){ - showGeocoderResults_Empty(marker_id); + showGeocoderResults_Empty(parameters); return; } if(response.length == 0) { - showGeocoderResults_Empty(marker_id); + showGeocoderResults_Empty(parameters); return; } @@ -90,7 +90,7 @@ function showGeocoderResults(response, marker_id) { html += ''; if(result.display_name){ - html += '
'+result.display_name+'
'; + html += '
'+result.display_name+'
'; } html += ""; } @@ -99,16 +99,16 @@ function showGeocoderResults(response, marker_id) { document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; document.getElementById('information-box').innerHTML = html; - onclickGeocoderResult(marker_id, response[0].lat, response[0].lon); + onclickGeocoderResult(parameters.marker_id, response[0].lat, response[0].lon); } -function showGeocoderResults_Empty(marker_id) { +function showGeocoderResults_Empty(parameters) { document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; - if(marker_id == OSRM.C.SOURCE_LABEL) - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+".

"; - else if(marker_id == OSRM.C.TARGET_LABEL) - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+".

"; + if(parameters.marker_id == OSRM.C.SOURCE_LABEL) + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +".

"; + else if(parameters.marker_id == OSRM.C.TARGET_LABEL) + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +".

"; else - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND")+".

"; + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +".

"; } function showGeocoderResults_Timeout() { document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; diff --git a/WebContent/main.html b/WebContent/main.html index dc2c30c3c..613b894c4 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -1,4 +1,4 @@ - + - + diff --git a/WebContent/main.js b/WebContent/main.js index 89fcbdf42..bf6d80d13 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -32,7 +32,7 @@ function init() { initRouting(); // check if the URL contains some GET parameter, e.g. for the route - checkURL(); + checkURL(); } @@ -92,12 +92,12 @@ function initLocale() { // centering on geolocation -function callbak_centerOnGeolocation( position ) { +function callback_centerOnGeolocation( position ) { OSRM.G.map.setView( new L.LatLng( position.coords.latitude, position.coords.longitude), OSRM.DEFAULTS.ZOOM_LEVEL); } function centerOnGeolocation() { if (navigator.geolocation) - navigator.geolocation.getCurrentPosition( callbak_centerOnGeolocation ); + navigator.geolocation.getCurrentPosition( callback_centerOnGeolocation ); } diff --git a/WebContent/routing.js b/WebContent/routing.js index 41f44dbde..52b9818e5 100644 --- a/WebContent/routing.js +++ b/WebContent/routing.js @@ -159,7 +159,7 @@ function showRouteDescription(response) { route_desc += ''; route_desc += ''; - route_desc += ''; + route_desc += ''; route_desc += ""; route_desc += '';