geocoder error messages now state the input string,

website is XHTML1.0 strict compliant,
centering now respects if the sidebar is shown,
corrected spelling mistakes
This commit is contained in:
DennisSchiefer 2012-03-22 17:35:09 +01:00
parent 4e2e95cc27
commit bef41ed667
6 changed files with 44 additions and 20 deletions

View File

@ -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+")";

View File

@ -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())

View File

@ -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 += '<td class="result-items">';
if(result.display_name){
html += '<div class="result-item" onclick="onclickGeocoderResult(\''+marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
html += '<div class="result-item" onclick="onclickGeocoderResult(\''+parameters.marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
}
html += "</td></tr>";
}
@ -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 = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+".<p>";
else if(marker_id == OSRM.C.TARGET_LABEL)
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+".<p>";
if(parameters.marker_id == OSRM.C.SOURCE_LABEL)
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +".<p>";
else if(parameters.marker_id == OSRM.C.TARGET_LABEL)
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +".<p>";
else
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+".<p>";
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +".<p>";
}
function showGeocoderResults_Timeout() {
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";

View File

@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
-->
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- head -->

View File

@ -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 );
}

View File

@ -159,7 +159,7 @@ function showRouteDescription(response) {
route_desc += '<tr class="'+rowstyle+'">';
route_desc += '<td class="result-directions">';
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'"/>';
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'" alt="" />';
route_desc += "</td>";
route_desc += '<td class="result-items">';