used abbreviations for sub-namespaces GLOBALS, CONSTANTS
This commit is contained in:
parent
13126ac0c1
commit
3e4249ad41
@ -109,21 +109,21 @@ onClick: function(e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
OSRM.G.markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
},
|
},
|
||||||
onDrag: function(e) {
|
onDrag: function(e) {
|
||||||
this.parent.dirty_move = true;
|
this.parent.dirty_move = true;
|
||||||
this.parent.setPosition( e.target.getLatLng() );
|
this.parent.setPosition( e.target.getLatLng() );
|
||||||
if(OSRM.GLOBALS.dragging == true) // TODO: hack that deals with drag events after dragend event
|
if(OSRM.G.dragging == true) // TODO: hack that deals with drag events after dragend event
|
||||||
getRoute(OSRM.CONSTANTS.NO_DESCRIPTION);
|
getRoute(OSRM.C.NO_DESCRIPTION);
|
||||||
else
|
else
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragStart: function(e) {
|
onDragStart: function(e) {
|
||||||
OSRM.GLOBALS.dragging = true;
|
OSRM.G.dragging = true;
|
||||||
|
|
||||||
// hack to store id of dragged marker
|
// hack to store id of dragged marker
|
||||||
for( var i=0; i<OSRM.G.markers.route.length; i++)
|
for( var i=0; i<OSRM.G.markers.route.length; i++)
|
||||||
@ -140,19 +140,19 @@ onDragStart: function(e) {
|
|||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragEnd: function(e) {
|
onDragEnd: function(e) {
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
if (OSRM.G.route.isShown()) {
|
if (OSRM.G.route.isShown()) {
|
||||||
OSRM.G.route.hideOldRoute();
|
OSRM.G.route.hideOldRoute();
|
||||||
OSRM.G.route.hideUnnamedRoute();
|
OSRM.G.route.hideUnnamedRoute();
|
||||||
}
|
}
|
||||||
OSRM.GLOBALS.dragging = false;
|
OSRM.G.dragging = false;
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
if(OSRM.G.route.isShown()==false) {
|
if(OSRM.G.route.isShown()==false) {
|
||||||
if(this.parent.label == OSRM.CONSTANTS.SOURCE_LABEL)
|
if(this.parent.label == OSRM.C.SOURCE_LABEL)
|
||||||
updateReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL);
|
updateReverseGeocoder(OSRM.C.SOURCE_LABEL);
|
||||||
else if(this.parent.label == OSRM.CONSTANTS.TARGET_LABEL)
|
else if(this.parent.label == OSRM.C.TARGET_LABEL)
|
||||||
updateReverseGeocoder(OSRM.CONSTANTS.TARGET_LABEL);
|
updateReverseGeocoder(OSRM.C.TARGET_LABEL);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
@ -181,18 +181,18 @@ removeVias: function() {
|
|||||||
},
|
},
|
||||||
setSource: function(position) {
|
setSource: function(position) {
|
||||||
// source node is always first node
|
// source node is always first node
|
||||||
if( this.route[0] && this.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
if( this.route[0] && this.route[0].label == OSRM.C.SOURCE_LABEL )
|
||||||
this.route[0].setPosition(position);
|
this.route[0].setPosition(position);
|
||||||
else
|
else
|
||||||
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.CONSTANTS.SOURCE_LABEL, {draggable:true,icon:OSRM.icons['marker-source']}, position));
|
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.C.SOURCE_LABEL, {draggable:true,icon:OSRM.icons['marker-source']}, position));
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
setTarget: function(position) {
|
setTarget: function(position) {
|
||||||
// target node is always last node
|
// target node is always last node
|
||||||
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.CONSTANTS.TARGET_LABEL )
|
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL )
|
||||||
this.route[this.route.length-1].setPosition(position);
|
this.route[this.route.length-1].setPosition(position);
|
||||||
else
|
else
|
||||||
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.CONSTANTS.TARGET_LABEL, {draggable:true,icon:OSRM.icons['marker-target']}, position));
|
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.C.TARGET_LABEL, {draggable:true,icon:OSRM.icons['marker-target']}, position));
|
||||||
return this.route.length-1;
|
return this.route.length-1;
|
||||||
},
|
},
|
||||||
setVia: function(id, position) {
|
setVia: function(id, position) {
|
||||||
@ -200,7 +200,7 @@ setVia: function(id, position) {
|
|||||||
if( this.route.length<2 || id > this.route.length-2 )
|
if( this.route.length<2 || id > this.route.length-2 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.CONSTANTS.VIA_LABEL, {draggable:true,icon:OSRM.icons['marker-via']}, position));
|
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.icons['marker-via']}, position));
|
||||||
return id+1;
|
return id+1;
|
||||||
},
|
},
|
||||||
removeMarker: function(id) {
|
removeMarker: function(id) {
|
||||||
@ -208,9 +208,9 @@ removeMarker: function(id) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// also remove vias if source or target are removed
|
// also remove vias if source or target are removed
|
||||||
if( id==0 && this.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
if( id==0 && this.route[0].label == OSRM.C.SOURCE_LABEL )
|
||||||
this.removeVias();
|
this.removeVias();
|
||||||
else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.CONSTANTS.TARGET_LABEL ) {
|
else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL ) {
|
||||||
this.removeVias();
|
this.removeVias();
|
||||||
id = this.route.length-1;
|
id = this.route.length-1;
|
||||||
}
|
}
|
||||||
@ -219,12 +219,12 @@ removeMarker: function(id) {
|
|||||||
this.route.splice(id, 1);
|
this.route.splice(id, 1);
|
||||||
},
|
},
|
||||||
hasSource: function() {
|
hasSource: function() {
|
||||||
if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
hasTarget: function() {
|
hasTarget: function() {
|
||||||
if( OSRM.G.markers.route[OSRM.G.markers.route.length-1] && OSRM.G.markers.route[OSRM.G.markers.route.length-1].label == OSRM.CONSTANTS.TARGET_LABEL )
|
if( OSRM.G.markers.route[OSRM.G.markers.route.length-1] && OSRM.G.markers.route[OSRM.G.markers.route.length-1].label == OSRM.C.TARGET_LABEL )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@ OSRM.CONSTANTS.VIA_LABEL = "via";
|
|||||||
|
|
||||||
// update geo coordinates in input boxes
|
// update geo coordinates in input boxes
|
||||||
function updateLocation(marker_id) {
|
function updateLocation(marker_id) {
|
||||||
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.route[0].dirty_move == true ) {
|
if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.route[0].dirty_move == true ) {
|
||||||
document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[0].getPosition().lng.toFixed(6);
|
document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[0].getPosition().lng.toFixed(6);
|
||||||
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move == true) {
|
} else if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move == true) {
|
||||||
document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng.toFixed(6);
|
document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,9 +37,9 @@ function updateLocation(marker_id) {
|
|||||||
|
|
||||||
// process input request and call geocoder if needed
|
// process input request and call geocoder if needed
|
||||||
function callGeocoder(marker_id, query) {
|
function callGeocoder(marker_id, query) {
|
||||||
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.hasSource() && OSRM.G.markers.route[0].dirty_move == false && OSRM.G.markers.route[0].dirty_type == false)
|
if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() && OSRM.G.markers.route[0].dirty_move == false && OSRM.G.markers.route[0].dirty_type == false)
|
||||||
return;
|
return;
|
||||||
if (marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.hasTarget() && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move == false && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type == false)
|
if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move == false && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type == false)
|
||||||
return;
|
return;
|
||||||
if(query=="")
|
if(query=="")
|
||||||
return;
|
return;
|
||||||
@ -52,10 +52,10 @@ function callGeocoder(marker_id, query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//build request
|
//build request
|
||||||
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
if (marker_id == OSRM.C.SOURCE_LABEL) {
|
||||||
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
||||||
OSRM.JSONP.call( call, showGeocoderResults_Source, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_source" );
|
OSRM.JSONP.call( call, showGeocoderResults_Source, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_source" );
|
||||||
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
} else if (marker_id == OSRM.C.TARGET_LABEL) {
|
||||||
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
||||||
OSRM.JSONP.call( call, showGeocoderResults_Target, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_target" );
|
OSRM.JSONP.call( call, showGeocoderResults_Target, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_target" );
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ function callGeocoder(marker_id, query) {
|
|||||||
// helper function for clicks on geocoder search results
|
// helper function for clicks on geocoder search results
|
||||||
function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
||||||
var index;
|
var index;
|
||||||
if( marker_id == OSRM.CONSTANTS.SOURCE_LABEL )
|
if( marker_id == OSRM.C.SOURCE_LABEL )
|
||||||
index = OSRM.G.markers.setSource( new L.LatLng(lat, lon) );
|
index = OSRM.G.markers.setSource( new L.LatLng(lat, lon) );
|
||||||
else if( marker_id == OSRM.CONSTANTS.TARGET_LABEL )
|
else if( marker_id == OSRM.C.TARGET_LABEL )
|
||||||
index = OSRM.G.markers.setTarget( new L.LatLng(lat, lon) );
|
index = OSRM.G.markers.setTarget( new L.LatLng(lat, lon) );
|
||||||
else
|
else
|
||||||
index = -1; // via nodes not yet implemented
|
index = -1; // via nodes not yet implemented
|
||||||
@ -80,7 +80,7 @@ function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
|||||||
OSRM.G.markers.route[index].show();
|
OSRM.G.markers.route[index].show();
|
||||||
if( !OSRM.G.markers.route[index].dirty_move || OSRM.G.markers.route[index].dirty_type )
|
if( !OSRM.G.markers.route[index].dirty_move || OSRM.G.markers.route[index].dirty_type )
|
||||||
OSRM.G.markers.route[index].centerView(zoom);
|
OSRM.G.markers.route[index].centerView(zoom);
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
|
|
||||||
OSRM.G.markers.route[index].dirty_move = false;
|
OSRM.G.markers.route[index].dirty_move = false;
|
||||||
OSRM.G.markers.route[index].dirty_type = false;
|
OSRM.G.markers.route[index].dirty_type = false;
|
||||||
@ -88,8 +88,8 @@ function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
|||||||
|
|
||||||
// process JSONP response of geocoder
|
// process JSONP response of geocoder
|
||||||
// (with wrapper functions for source/target jsonp)
|
// (with wrapper functions for source/target jsonp)
|
||||||
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.CONSTANTS.SOURCE_LABEL, response); }
|
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.C.SOURCE_LABEL, response); }
|
||||||
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.CONSTANTS.TARGET_LABEL, response); }
|
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.C.TARGET_LABEL, response); }
|
||||||
function showGeocoderResults(marker_id, response) {
|
function showGeocoderResults(marker_id, response) {
|
||||||
if(response){
|
if(response){
|
||||||
if(response.length == 0) {
|
if(response.length == 0) {
|
||||||
@ -125,9 +125,9 @@ function showGeocoderResults(marker_id, response) {
|
|||||||
}
|
}
|
||||||
function showGeocoderResults_Empty(marker_id) {
|
function showGeocoderResults_Empty(marker_id) {
|
||||||
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
if(marker_id == OSRM.CONSTANTS.SOURCE_LABEL)
|
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>";
|
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.CONSTANTS.TARGET_LABEL)
|
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>";
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+".<p>";
|
||||||
else
|
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")+".<p>";
|
||||||
@ -142,22 +142,22 @@ function showGeocoderResults_Timeout() {
|
|||||||
|
|
||||||
//update reverse geocoder informatiopn in input boxes
|
//update reverse geocoder informatiopn in input boxes
|
||||||
function updateReverseGeocoder(marker_id) {
|
function updateReverseGeocoder(marker_id) {
|
||||||
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.hasSource()) { //&& OSRM.G.markers.route[0].dirty == true ) {
|
if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) { //&& OSRM.G.markers.route[0].dirty == true ) {
|
||||||
//document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[0].getPosition().lng.toFixed(6);
|
//document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[0].getPosition().lng.toFixed(6);
|
||||||
callReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL, OSRM.G.markers.route[0].getPosition().lat, OSRM.G.markers.route[0].getPosition().lng);
|
callReverseGeocoder(OSRM.C.SOURCE_LABEL, OSRM.G.markers.route[0].getPosition().lat, OSRM.G.markers.route[0].getPosition().lng);
|
||||||
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.hasTarget()) { //&& OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty == true) {
|
} else if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget()) { //&& OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty == true) {
|
||||||
//document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng.toFixed(6);
|
//document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
callReverseGeocoder(OSRM.CONSTANTS.TARGET_LABEL, OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat, OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng);
|
callReverseGeocoder(OSRM.C.TARGET_LABEL, OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat, OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//prepare request and call reverse geocoder
|
//prepare request and call reverse geocoder
|
||||||
function callReverseGeocoder(marker_id, lat, lon) {
|
function callReverseGeocoder(marker_id, lat, lon) {
|
||||||
//build request
|
//build request
|
||||||
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
if (marker_id == OSRM.C.SOURCE_LABEL) {
|
||||||
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
||||||
OSRM.JSONP.call( call, showReverseGeocoderResults_Source, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_source" );
|
OSRM.JSONP.call( call, showReverseGeocoderResults_Source, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_source" );
|
||||||
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
} else if (marker_id == OSRM.C.TARGET_LABEL) {
|
||||||
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
||||||
OSRM.JSONP.call( call, showReverseGeocoderResults_Target, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_target" );
|
OSRM.JSONP.call( call, showReverseGeocoderResults_Target, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_target" );
|
||||||
}
|
}
|
||||||
@ -165,8 +165,8 @@ function callReverseGeocoder(marker_id, lat, lon) {
|
|||||||
//processing JSONP response of reverse geocoder
|
//processing JSONP response of reverse geocoder
|
||||||
//(with wrapper functions for source/target jsonp)
|
//(with wrapper functions for source/target jsonp)
|
||||||
function showReverseGeocoderResults_Timeout() {}
|
function showReverseGeocoderResults_Timeout() {}
|
||||||
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.CONSTANTS.SOURCE_LABEL, response); }
|
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.C.SOURCE_LABEL, response); }
|
||||||
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.CONSTANTS.TARGET_LABEL, response); }
|
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.C.TARGET_LABEL, response); }
|
||||||
function showReverseGeocoderResults(marker_id, response) {
|
function showReverseGeocoderResults(marker_id, response) {
|
||||||
//OSRM.debug.log("[inner] reverse geocoder");
|
//OSRM.debug.log("[inner] reverse geocoder");
|
||||||
if(response){
|
if(response){
|
||||||
@ -190,11 +190,11 @@ function showReverseGeocoderResults(marker_id, response) {
|
|||||||
if( address == "" )
|
if( address == "" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
if(marker_id == OSRM.C.SOURCE_LABEL) {
|
||||||
document.getElementById("input-source-name").value = address;
|
document.getElementById("input-source-name").value = address;
|
||||||
OSRM.G.markers.route[0].dirty_move = false;
|
OSRM.G.markers.route[0].dirty_move = false;
|
||||||
OSRM.G.markers.route[0].dirty_type = false;
|
OSRM.G.markers.route[0].dirty_type = false;
|
||||||
} else if(marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
} else if(marker_id == OSRM.C.TARGET_LABEL) {
|
||||||
document.getElementById("input-target-name").value = address;
|
document.getElementById("input-target-name").value = address;
|
||||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move = false;
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move = false;
|
||||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = false;
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = false;
|
||||||
|
@ -88,13 +88,13 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
<table class="full">
|
<table class="full">
|
||||||
<tr>
|
<tr>
|
||||||
<td id="gui-search-source-label">Start:</td>
|
<td id="gui-search-source-label">Start:</td>
|
||||||
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="if( OSRM.G.markers.hasSource() ) OSRM.G.markers.route[0].dirty_type = true;" onblur="callGeocoder(OSRM.CONSTANTS.SOURCE_LABEL, document.getElementById('input-source-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.CONSTANTS.SOURCE_LABEL, document.getElementById('input-source-name').value);}" /></td>
|
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="if( OSRM.G.markers.hasSource() ) OSRM.G.markers.route[0].dirty_type = true;" onblur="callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);}" /></td>
|
||||||
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="centerMarker('source')">Zeigen</a></td>
|
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="centerMarker('source')">Zeigen</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td id="gui-search-target-label">Ende:</td>
|
<td id="gui-search-target-label">Ende:</td>
|
||||||
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="if( OSRM.G.markers.route.hasTarget() ) OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = true;" onblur="callGeocoder(OSRM.CONSTANTS.TARGET_LABEL, document.getElementById('input-target-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.CONSTANTS.TARGET_LABEL, document.getElementById('input-target-name').value);}" /></td>
|
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="if( OSRM.G.markers.route.hasTarget() ) OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = true;" onblur="callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);}" /></td>
|
||||||
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="centerMarker('target');">Zeigen</a></td>
|
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="centerMarker('target');">Zeigen</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -112,7 +112,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
<div class="vquad"></div>
|
<div class="vquad"></div>
|
||||||
<div class="main-options not-selectable" id="options-toggle" onclick="OSRM.GUI.toggleOptions()">Options</div>
|
<div class="main-options not-selectable" id="options-toggle" onclick="OSRM.GUI.toggleOptions()">Options</div>
|
||||||
<div class="main-options not-selectable" id="options-box">
|
<div class="main-options not-selectable" id="options-box">
|
||||||
<input type="checkbox" id="option-highlight-nonames" name="main-options" value="highlight-nonames" onclick="getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION)" /><span id="gui-option-highlight-nonames-label">Unbenannte Straßen hervorheben</span>
|
<input type="checkbox" id="option-highlight-nonames" name="main-options" value="highlight-nonames" onclick="getRoute(OSRM.C.FULL_DESCRIPTION)" /><span id="gui-option-highlight-nonames-label">Unbenannte Straßen hervorheben</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -152,15 +152,15 @@ function initMap() {
|
|||||||
|
|
||||||
// initial map position and zoom
|
// initial map position and zoom
|
||||||
OSRM.G.map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), OSRM.DEFAULTS.ZOOM_LEVEL);
|
OSRM.G.map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), OSRM.DEFAULTS.ZOOM_LEVEL);
|
||||||
OSRM.G.map.on('zoomend', function(e) { getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION); });
|
OSRM.G.map.on('zoomend', function(e) { getRoute(OSRM.C.FULL_DESCRIPTION); });
|
||||||
OSRM.G.map.on('contextmenu', function(e) {});
|
OSRM.G.map.on('contextmenu', function(e) {});
|
||||||
|
|
||||||
// click on map to set source and target nodes
|
// click on map to set source and target nodes
|
||||||
OSRM.G.map.on('click', function(e) {
|
OSRM.G.map.on('click', function(e) {
|
||||||
if( !OSRM.G.markers.hasSource() )
|
if( !OSRM.G.markers.hasSource() )
|
||||||
onclickGeocoderResult(OSRM.CONSTANTS.SOURCE_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
onclickGeocoderResult(OSRM.C.SOURCE_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
||||||
else if( !OSRM.G.markers.hasTarget() )
|
else if( !OSRM.G.markers.hasTarget() )
|
||||||
onclickGeocoderResult(OSRM.CONSTANTS.TARGET_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
onclickGeocoderResult(OSRM.C.TARGET_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ function checkURL(){
|
|||||||
|
|
||||||
// case 1: destination given
|
// case 1: destination given
|
||||||
if( destination != undefined ) {
|
if( destination != undefined ) {
|
||||||
onclickGeocoderResult(OSRM.CONSTANTS.TARGET_LABEL, destination.lat, destination.lng, (destination_name == undefined) );
|
onclickGeocoderResult(OSRM.C.TARGET_LABEL, destination.lat, destination.lng, (destination_name == undefined) );
|
||||||
if( destination_name != undefined )
|
if( destination_name != undefined )
|
||||||
document.getElementById("input-target-name").value = destination_name;
|
document.getElementById("input-target-name").value = destination_name;
|
||||||
return;
|
return;
|
||||||
@ -227,11 +227,11 @@ function checkURL(){
|
|||||||
if( positions != []) {
|
if( positions != []) {
|
||||||
// draw via points
|
// draw via points
|
||||||
if( positions.length > 0) {
|
if( positions.length > 0) {
|
||||||
onclickGeocoderResult(OSRM.CONSTANTS.SOURCE_LABEL, positions[0].lat, positions[0].lng, true, false );
|
onclickGeocoderResult(OSRM.C.SOURCE_LABEL, positions[0].lat, positions[0].lng, true, false );
|
||||||
//OSRM.G.markers.setSource( positions[0] );
|
//OSRM.G.markers.setSource( positions[0] );
|
||||||
}
|
}
|
||||||
if(positions.length > 1) {
|
if(positions.length > 1) {
|
||||||
onclickGeocoderResult(OSRM.CONSTANTS.TARGET_LABEL, positions[positions.length-1].lat, positions[positions.length-1].lng, true, false );
|
onclickGeocoderResult(OSRM.C.TARGET_LABEL, positions[positions.length-1].lat, positions[positions.length-1].lng, true, false );
|
||||||
//OSRM.G.markers.setTarget( positions[positions.length-1] );
|
//OSRM.G.markers.setTarget( positions[positions.length-1] );
|
||||||
}
|
}
|
||||||
for(var i=1; i<positions.length-1;i++)
|
for(var i=1; i<positions.length-1;i++)
|
||||||
@ -248,6 +248,6 @@ function checkURL(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute route
|
// compute route
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ function showRouteSimple(response) {
|
|||||||
updateHints(response);
|
updateHints(response);
|
||||||
|
|
||||||
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
||||||
// if(OSRM.GLOBALS.pending) {
|
// if(OSRM.G.pending) {
|
||||||
// clearTimeout(OSRM.GLOBALS.pendingTimer);
|
// clearTimeout(OSRM.G.pendingTimer);
|
||||||
// OSRM.GLOBALS.pendingTimer = setTimeout(timeoutDrag,100);
|
// OSRM.G.pendingTimer = setTimeout(timeoutDrag,100);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
function showRoute(response) {
|
function showRoute(response) {
|
||||||
@ -312,23 +312,23 @@ function getRoute(do_description) {
|
|||||||
|
|
||||||
// TODO: hack to process final drag event, if it was fenced, but we are still dragging
|
// TODO: hack to process final drag event, if it was fenced, but we are still dragging
|
||||||
if(called == false && !do_description) {
|
if(called == false && !do_description) {
|
||||||
clearTimeout(OSRM.GLOBALS.pendingTimer);
|
clearTimeout(OSRM.G.pendingTimer);
|
||||||
OSRM.GLOBALS.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
|
OSRM.G.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clearTimeout(OSRM.GLOBALS.pendingTimer);
|
clearTimeout(OSRM.G.pendingTimer);
|
||||||
}
|
}
|
||||||
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
||||||
// if(called == false && !do_description) {
|
// if(called == false && !do_description) {
|
||||||
// OSRM.GLOBALS.pending = true;
|
// OSRM.G.pending = true;
|
||||||
// } else {
|
// } else {
|
||||||
// clearTimeout(OSRM.GLOBALS.pendingTimer);
|
// clearTimeout(OSRM.G.pendingTimer);
|
||||||
// OSRM.GLOBALS.pending = false;
|
// OSRM.G.pending = false;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
function timeoutDrag() {
|
function timeoutDrag() {
|
||||||
OSRM.G.markers.route[OSRM.G.dragid].hint = undefined;
|
OSRM.G.markers.route[OSRM.G.dragid].hint = undefined;
|
||||||
getRoute(OSRM.CONSTANTS.NO_DESCRIPTION);
|
getRoute(OSRM.C.NO_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -378,13 +378,13 @@ function snapRoute() {
|
|||||||
for(var i=0; i<OSRM.G.via_points.length; i++)
|
for(var i=0; i<OSRM.G.via_points.length; i++)
|
||||||
OSRM.G.markers.route[i+1].setPosition( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
|
OSRM.G.markers.route[i+1].setPosition( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
|
||||||
|
|
||||||
// updateLocation( OSRM.CONSTANTS.SOURCE_LABEL );
|
// updateLocation( OSRM.C.SOURCE_LABEL );
|
||||||
// updateLocation( OSRM.CONSTANTS.TARGET_LABEL );
|
// updateLocation( OSRM.C.TARGET_LABEL );
|
||||||
|
|
||||||
//if(OSRM.G.dragid == 0 && OSRM.G.markers.hasSource())
|
//if(OSRM.G.dragid == 0 && OSRM.G.markers.hasSource())
|
||||||
updateReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL);
|
updateReverseGeocoder(OSRM.C.SOURCE_LABEL);
|
||||||
//else if(OSRM.G.dragid == OSRM.G.markers.route.length-1 && OSRM.G.markers.hasTarget())
|
//else if(OSRM.G.dragid == OSRM.G.markers.route.length-1 && OSRM.G.markers.hasTarget())
|
||||||
updateReverseGeocoder(OSRM.CONSTANTS.TARGET_LABEL);
|
updateReverseGeocoder(OSRM.C.TARGET_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// map driving instructions to icons
|
// map driving instructions to icons
|
||||||
@ -448,24 +448,24 @@ function reverseRouting() {
|
|||||||
// invert route
|
// invert route
|
||||||
OSRM.G.markers.route.reverse();
|
OSRM.G.markers.route.reverse();
|
||||||
if(OSRM.G.markers.route.length == 1) {
|
if(OSRM.G.markers.route.length == 1) {
|
||||||
if(OSRM.G.markers.route[0].label == OSRM.CONSTANTS.TARGET_LABEL) {
|
if(OSRM.G.markers.route[0].label == OSRM.C.TARGET_LABEL) {
|
||||||
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.SOURCE_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
|
||||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||||
} else if(OSRM.G.markers.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL) {
|
} else if(OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL) {
|
||||||
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.TARGET_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.C.TARGET_LABEL;
|
||||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') );
|
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||||
}
|
}
|
||||||
} else if(OSRM.G.markers.route.length > 1){
|
} else if(OSRM.G.markers.route.length > 1){
|
||||||
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.SOURCE_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
|
||||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||||
|
|
||||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.CONSTANTS.TARGET_LABEL;
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.C.TARGET_LABEL;
|
||||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') );
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||||
}
|
}
|
||||||
|
|
||||||
// recompute route
|
// recompute route
|
||||||
if( OSRM.G.route.isShown() ) {
|
if( OSRM.G.route.isShown() ) {
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
OSRM.G.markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('information-box').innerHTML = "";
|
document.getElementById('information-box').innerHTML = "";
|
||||||
@ -475,9 +475,9 @@ function reverseRouting() {
|
|||||||
|
|
||||||
// click: button "show"
|
// click: button "show"
|
||||||
function centerMarker(marker_id) {
|
function centerMarker(marker_id) {
|
||||||
if( marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.hasSource() && !OSRM.G.markers.route[0].dirty_type ) {
|
if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() && !OSRM.G.markers.route[0].dirty_type ) {
|
||||||
OSRM.G.markers.route[0].centerView();
|
OSRM.G.markers.route[0].centerView();
|
||||||
} else if( marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.hasTarget() && !OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type) {
|
} else if( marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() && !OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type) {
|
||||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ function findViaPosition( new_via_position ) {
|
|||||||
var index = OSRM.G.markers.setVia(new_via_index, new_via_position);
|
var index = OSRM.G.markers.setVia(new_via_index, new_via_position);
|
||||||
OSRM.G.markers.route[index].show();
|
OSRM.G.markers.route[index].show();
|
||||||
|
|
||||||
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
getRoute(OSRM.C.FULL_DESCRIPTION);
|
||||||
|
|
||||||
return new_via_index;
|
return new_via_index;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user