moved all variables/objects to OSRM namespace
This commit is contained in:
parent
d51aee4fbe
commit
13126ac0c1
@ -34,11 +34,11 @@ OSRM.Marker = function( label, style, position ) {
|
|||||||
};
|
};
|
||||||
OSRM.extend( OSRM.Marker,{
|
OSRM.extend( OSRM.Marker,{
|
||||||
show: function() {
|
show: function() {
|
||||||
map.addLayer(this.marker);
|
OSRM.G.map.addLayer(this.marker);
|
||||||
this.shown = true;
|
this.shown = true;
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function() {
|
||||||
map.removeLayer(this.marker);
|
OSRM.G.map.removeLayer(this.marker);
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
},
|
},
|
||||||
setPosition: function( position ) {
|
setPosition: function( position ) {
|
||||||
@ -61,9 +61,9 @@ isShown: function() {
|
|||||||
centerView: function(zooming) {
|
centerView: function(zooming) {
|
||||||
var zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
|
var zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
|
||||||
if( zooming == false )
|
if( zooming == false )
|
||||||
zoom = map.getZoom();
|
zoom = OSRM.G.map.getZoom();
|
||||||
//map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), zoom); // dirty hack
|
//OSRM.G.map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), zoom); // dirty hack
|
||||||
map.setView( new L.LatLng( this.position.lat, this.position.lng), zoom);
|
OSRM.G.map.setView( new L.LatLng( this.position.lat, this.position.lng), zoom);
|
||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
||||||
@ -102,57 +102,57 @@ OSRM.RouteMarker = function ( label, style, position ) {
|
|||||||
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
||||||
OSRM.extend( OSRM.RouteMarker, {
|
OSRM.extend( OSRM.RouteMarker, {
|
||||||
onClick: function(e) {
|
onClick: function(e) {
|
||||||
for( var i=0; i<my_markers.route.length; i++) {
|
for( var i=0; i<OSRM.G.markers.route.length; i++) {
|
||||||
if( my_markers.route[i].marker === this ) {
|
if( OSRM.G.markers.route[i].marker === this ) {
|
||||||
my_markers.removeMarker( i );
|
OSRM.G.markers.removeMarker( i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
my_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.dragging == true) // TODO: hack that deals with drag events after dragend event
|
if(OSRM.GLOBALS.dragging == true) // TODO: hack that deals with drag events after dragend event
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.NO_DESCRIPTION);
|
||||||
else
|
else
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragStart: function(e) {
|
onDragStart: function(e) {
|
||||||
OSRM.dragging = true;
|
OSRM.GLOBALS.dragging = true;
|
||||||
|
|
||||||
// hack to store id of dragged marker
|
// hack to store id of dragged marker
|
||||||
for( var i=0; i<my_markers.route.length; i++)
|
for( var i=0; i<OSRM.G.markers.route.length; i++)
|
||||||
if( my_markers.route[i].marker === this ) {
|
if( OSRM.G.markers.route[i].marker === this ) {
|
||||||
OSRM.dragid = i;
|
OSRM.G.dragid = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
if (my_route.isShown()) {
|
if (OSRM.G.route.isShown()) {
|
||||||
my_route.showOldRoute();
|
OSRM.G.route.showOldRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragEnd: function(e) {
|
onDragEnd: function(e) {
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
if (my_route.isShown()) {
|
if (OSRM.G.route.isShown()) {
|
||||||
my_route.hideOldRoute();
|
OSRM.G.route.hideOldRoute();
|
||||||
my_route.hideUnnamedRoute();
|
OSRM.G.route.hideUnnamedRoute();
|
||||||
}
|
}
|
||||||
OSRM.dragging = false;
|
OSRM.GLOBALS.dragging = false;
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
if(my_route.isShown()==false) {
|
if(OSRM.G.route.isShown()==false) {
|
||||||
if(this.parent.label == "source")
|
if(this.parent.label == OSRM.CONSTANTS.SOURCE_LABEL)
|
||||||
updateReverseGeocoder("source");
|
updateReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL);
|
||||||
else if(this.parent.label == "target")
|
else if(this.parent.label == OSRM.CONSTANTS.TARGET_LABEL)
|
||||||
updateReverseGeocoder("target");
|
updateReverseGeocoder(OSRM.CONSTANTS.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.SOURCE_MARKER_LABEL )
|
if( this.route[0] && this.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
||||||
this.route[0].setPosition(position);
|
this.route[0].setPosition(position);
|
||||||
else
|
else
|
||||||
this.route.splice(0,0, new OSRM.RouteMarker("source", {draggable:true,icon:OSRM.icons['marker-source']}, position));
|
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.CONSTANTS.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.TARGET_MARKER_LABEL )
|
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.CONSTANTS.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("target", {draggable:true,icon:OSRM.icons['marker-target']}, position));
|
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.CONSTANTS.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("via", {draggable:true,icon:OSRM.icons['marker-via']}, position));
|
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.CONSTANTS.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.SOURCE_MARKER_LABEL )
|
if( id==0 && this.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
||||||
this.removeVias();
|
this.removeVias();
|
||||||
else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.TARGET_MARKER_LABEL ) {
|
else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.CONSTANTS.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( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL )
|
if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
hasTarget: function() {
|
hasTarget: function() {
|
||||||
if( my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL )
|
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 )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ OSRM.SimpleRoute = function (label, style) {
|
|||||||
};
|
};
|
||||||
OSRM.extend( OSRM.SimpleRoute,{
|
OSRM.extend( OSRM.SimpleRoute,{
|
||||||
show: function() {
|
show: function() {
|
||||||
map.addLayer(this.route);
|
OSRM.G.map.addLayer(this.route);
|
||||||
this.shown = true;
|
this.shown = true;
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function() {
|
||||||
map.removeLayer(this.route);
|
OSRM.G.map.removeLayer(this.route);
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
},
|
},
|
||||||
isShown: function() {
|
isShown: function() {
|
||||||
@ -53,10 +53,10 @@ setStyle: function(style) {
|
|||||||
},
|
},
|
||||||
centerView: function() {
|
centerView: function() {
|
||||||
var bounds = new L.LatLngBounds( this.getPositions() );
|
var bounds = new L.LatLngBounds( this.getPositions() );
|
||||||
map.fitBounds( bounds );
|
OSRM.G.map.fitBounds( bounds );
|
||||||
},
|
},
|
||||||
onClick: function(e) {
|
onClick: function(e) {
|
||||||
if(my_route.isRoute())
|
if(OSRM.G.route.isRoute())
|
||||||
findViaPosition( e.latlng );
|
findViaPosition( e.latlng );
|
||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
@ -74,11 +74,11 @@ OSRM.MultiRoute = function (label) {
|
|||||||
};
|
};
|
||||||
OSRM.extend( OSRM.MultiRoute,{
|
OSRM.extend( OSRM.MultiRoute,{
|
||||||
show: function() {
|
show: function() {
|
||||||
map.addLayer(this.route);
|
OSRM.G.map.addLayer(this.route);
|
||||||
this.shown = true;
|
this.shown = true;
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function() {
|
||||||
map.removeLayer(this.route);
|
OSRM.G.map.removeLayer(this.route);
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
},
|
},
|
||||||
isShown: function() {
|
isShown: function() {
|
||||||
@ -86,7 +86,7 @@ isShown: function() {
|
|||||||
},
|
},
|
||||||
addRoute: function(positions) {
|
addRoute: function(positions) {
|
||||||
var line = new L.DashedPolyline( positions );
|
var line = new L.DashedPolyline( positions );
|
||||||
line.on('click', function(e) { my_route.fire('click',e); });
|
line.on('click', function(e) { OSRM.G.route.fire('click',e); });
|
||||||
this.route.addLayer( line );
|
this.route.addLayer( line );
|
||||||
},
|
},
|
||||||
clearRoutes: function() {
|
clearRoutes: function() {
|
||||||
|
@ -23,6 +23,8 @@ OSRM.VERSION = '0.1.1';
|
|||||||
OSRM.CONSTANTS = {};
|
OSRM.CONSTANTS = {};
|
||||||
OSRM.DEFAULTS = {};
|
OSRM.DEFAULTS = {};
|
||||||
OSRM.GLOBALS = {};
|
OSRM.GLOBALS = {};
|
||||||
|
OSRM.G = OSRM.GLOBALS; // abbreviations
|
||||||
|
OSRM.C = OSRM.CONSTANTS;
|
||||||
|
|
||||||
|
|
||||||
// [convenience function] declare one class to be a subclass of another class
|
// [convenience function] declare one class to be a subclass of another class
|
||||||
|
@ -21,6 +21,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
OSRM.DEFAULTS = {
|
OSRM.DEFAULTS = {
|
||||||
HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute',
|
HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute',
|
||||||
HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/',
|
HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/',
|
||||||
|
HOST_GEOCODER_URL: 'http://nominatim.openstreetmap.org/search',
|
||||||
|
HOST_REVERSE_GEOCODER_URL: 'http://nominatim.openstreetmap.org/reverse',
|
||||||
WEBSITE_URL: document.URL.replace(/#*(\?.*|$)/i,""), // truncates URL before first ?, and removes tailing #
|
WEBSITE_URL: document.URL.replace(/#*(\?.*|$)/i,""), // truncates URL before first ?, and removes tailing #
|
||||||
JSONP_TIMEOUT: 5000,
|
JSONP_TIMEOUT: 5000,
|
||||||
ZOOM_LEVEL: 14,
|
ZOOM_LEVEL: 14,
|
||||||
@ -28,5 +30,6 @@ OSRM.DEFAULTS = {
|
|||||||
ONLOAD_LONGITUDE: 10.10,
|
ONLOAD_LONGITUDE: 10.10,
|
||||||
ONLOAD_SOURCE: "",
|
ONLOAD_SOURCE: "",
|
||||||
ONLOAD_TARGET: "",
|
ONLOAD_TARGET: "",
|
||||||
LANGUAGE: "en"
|
LANGUAGE: "en",
|
||||||
|
GEOCODER_BOUNDS: '&bounded=1&viewbox=-27.0,72.0,46.0,36.0'
|
||||||
};
|
};
|
||||||
|
@ -20,26 +20,26 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
// [TODO: better separation of GUI and geocoding routines, reverse geocoding]
|
// [TODO: better separation of GUI and geocoding routines, reverse geocoding]
|
||||||
|
|
||||||
// some constants
|
// some constants
|
||||||
OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0';
|
OSRM.CONSTANTS.SOURCE_LABEL = "source";
|
||||||
OSRM.SOURCE_MARKER_LABEL = "source";
|
OSRM.CONSTANTS.TARGET_LABEL = "target";
|
||||||
OSRM.TARGET_MARKER_LABEL = "target";
|
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.SOURCE_MARKER_LABEL && my_markers.route[0].dirty_move == true ) {
|
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.route[0].dirty_move == true ) {
|
||||||
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_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.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1].dirty_move == true) {
|
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move == true) {
|
||||||
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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.SOURCE_MARKER_LABEL && my_markers.hasSource() && my_markers.route[0].dirty_move == false && my_markers.route[0].dirty_type == false)
|
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)
|
||||||
return;
|
return;
|
||||||
if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.hasTarget() && my_markers.route[my_markers.route.length-1].dirty_move == false && my_markers.route[my_markers.route.length-1].dirty_type == false)
|
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)
|
||||||
return;
|
return;
|
||||||
if(query=="")
|
if(query=="")
|
||||||
return;
|
return;
|
||||||
@ -52,12 +52,12 @@ function callGeocoder(marker_id, query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//build request
|
//build request
|
||||||
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
||||||
var src= OSRM.GEOCODE_POST + "&q=" + query;
|
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
||||||
OSRM.JSONP.call( src, 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.TARGET_MARKER_LABEL) {
|
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
||||||
var src = OSRM.GEOCODE_POST + "&q=" + query;
|
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
|
||||||
OSRM.JSONP.call( src, 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,10 +65,10 @@ 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.SOURCE_MARKER_LABEL )
|
if( marker_id == OSRM.CONSTANTS.SOURCE_LABEL )
|
||||||
index = my_markers.setSource( new L.LatLng(lat, lon) );
|
index = OSRM.G.markers.setSource( new L.LatLng(lat, lon) );
|
||||||
else if( marker_id == OSRM.TARGET_MARKER_LABEL )
|
else if( marker_id == OSRM.CONSTANTS.TARGET_LABEL )
|
||||||
index = my_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
|
||||||
|
|
||||||
@ -77,19 +77,19 @@ function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
|||||||
if( zoom == undefined )
|
if( zoom == undefined )
|
||||||
zoom = true;
|
zoom = true;
|
||||||
|
|
||||||
my_markers.route[index].show();
|
OSRM.G.markers.route[index].show();
|
||||||
if( !my_markers.route[index].dirty_move || my_markers.route[index].dirty_type )
|
if( !OSRM.G.markers.route[index].dirty_move || OSRM.G.markers.route[index].dirty_type )
|
||||||
my_markers.route[index].centerView(zoom);
|
OSRM.G.markers.route[index].centerView(zoom);
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
|
|
||||||
my_markers.route[index].dirty_move = false;
|
OSRM.G.markers.route[index].dirty_move = false;
|
||||||
my_markers.route[index].dirty_type = false;
|
OSRM.G.markers.route[index].dirty_type = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.SOURCE_MARKER_LABEL, response); }
|
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.CONSTANTS.SOURCE_LABEL, response); }
|
||||||
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.CONSTANTS.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.SOURCE_MARKER_LABEL)
|
if(marker_id == OSRM.CONSTANTS.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.TARGET_MARKER_LABEL)
|
else if(marker_id == OSRM.CONSTANTS.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>";
|
||||||
@ -139,35 +139,34 @@ function showGeocoderResults_Timeout() {
|
|||||||
|
|
||||||
|
|
||||||
// - [upcoming feature: reverse geocoding (untested) ] -
|
// - [upcoming feature: reverse geocoding (untested) ] -
|
||||||
OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0';
|
|
||||||
|
|
||||||
//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.SOURCE_MARKER_LABEL && my_markers.hasSource()) { //&& my_markers.route[0].dirty == true ) {
|
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.hasSource()) { //&& OSRM.G.markers.route[0].dirty == true ) {
|
||||||
//document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_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("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
callReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL, OSRM.G.markers.route[0].getPosition().lat, OSRM.G.markers.route[0].getPosition().lng);
|
||||||
} else if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.hasTarget()) { //&& my_markers.route[my_markers.route.length-1].dirty == true) {
|
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.hasTarget()) { //&& OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty == true) {
|
||||||
//document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_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("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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.SOURCE_MARKER_LABEL) {
|
if (marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
||||||
var src= OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
||||||
OSRM.JSONP.call( src, 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.TARGET_MARKER_LABEL) {
|
} else if (marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
||||||
var src = OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lon;
|
||||||
OSRM.JSONP.call( src, 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" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//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.SOURCE_MARKER_LABEL, response); }
|
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.CONSTANTS.SOURCE_LABEL, response); }
|
||||||
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.CONSTANTS.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){
|
||||||
@ -191,14 +190,14 @@ function showReverseGeocoderResults(marker_id, response) {
|
|||||||
if( address == "" )
|
if( address == "" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
if(marker_id == OSRM.CONSTANTS.SOURCE_LABEL) {
|
||||||
document.getElementById("input-source-name").value = address;
|
document.getElementById("input-source-name").value = address;
|
||||||
my_markers.route[0].dirty_move = false;
|
OSRM.G.markers.route[0].dirty_move = false;
|
||||||
my_markers.route[0].dirty_type = false;
|
OSRM.G.markers.route[0].dirty_type = false;
|
||||||
} else if(marker_id == OSRM.TARGET_MARKER_LABEL) {
|
} else if(marker_id == OSRM.CONSTANTS.TARGET_LABEL) {
|
||||||
document.getElementById("input-target-name").value = address;
|
document.getElementById("input-target-name").value = address;
|
||||||
my_markers.route[my_markers.route.length-1].dirty_move = false;
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_move = false;
|
||||||
my_markers.route[my_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( my_markers.hasSource() ) my_markers.route[0].dirty_type = true;" onblur="callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.SOURCE_MARKER_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.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 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( my_markers.route.hasTarget() ) my_markers.route[my_markers.route.length-1].dirty_type = true;" onblur="callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.TARGET_MARKER_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.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 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.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.CONSTANTS.FULL_DESCRIPTION)" /><span id="gui-option-highlight-nonames-label">Unbenannte Straßen hervorheben</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
// OSRM initialization
|
// OSRM initialization
|
||||||
// [initialization of maps, local strings, image prefetching]
|
// [initialization of maps, local strings, image prefetching]
|
||||||
|
|
||||||
var map;
|
// will hold the Leaflet map object
|
||||||
|
OSRM.GLOBALS.map = null;
|
||||||
|
|
||||||
|
|
||||||
// onload initialization routine
|
// onload initialization routine
|
||||||
@ -92,7 +93,7 @@ function initLocale() {
|
|||||||
|
|
||||||
// centering on geolocation
|
// centering on geolocation
|
||||||
function callbak_centerOnGeolocation( position ) {
|
function callbak_centerOnGeolocation( position ) {
|
||||||
map.setView( new L.LatLng( position.coords.latitude, position.coords.longitude-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
|
OSRM.G.map.setView( new L.LatLng( position.coords.latitude, position.coords.longitude-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
|
||||||
}
|
}
|
||||||
function centerOnGeolocation() {
|
function centerOnGeolocation() {
|
||||||
if (navigator.geolocation)
|
if (navigator.geolocation)
|
||||||
@ -125,7 +126,7 @@ function initMap() {
|
|||||||
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
|
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
|
||||||
|
|
||||||
// setup map
|
// setup map
|
||||||
map = new L.Map('map', {
|
OSRM.G.map = new L.Map('map', {
|
||||||
center: new L.LatLng(51.505, -0.09),
|
center: new L.LatLng(51.505, -0.09),
|
||||||
zoom: 13,
|
zoom: 13,
|
||||||
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
|
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
|
||||||
@ -143,23 +144,23 @@ function initMap() {
|
|||||||
|
|
||||||
var overlayMaps = {};
|
var overlayMaps = {};
|
||||||
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
||||||
map.addControl(layersControl);
|
OSRM.G.map.addControl(layersControl);
|
||||||
|
|
||||||
// move zoom markers
|
// move zoom markers
|
||||||
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
||||||
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
||||||
|
|
||||||
// initial map position and zoom
|
// initial map position and zoom
|
||||||
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);
|
||||||
map.on('zoomend', function(e) { getRoute(OSRM.FULL_DESCRIPTION); });
|
OSRM.G.map.on('zoomend', function(e) { getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION); });
|
||||||
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
|
||||||
map.on('click', function(e) {
|
OSRM.G.map.on('click', function(e) {
|
||||||
if( !my_markers.hasSource() )
|
if( !OSRM.G.markers.hasSource() )
|
||||||
onclickGeocoderResult("source", e.latlng.lat, e.latlng.lng, true, false );
|
onclickGeocoderResult(OSRM.CONSTANTS.SOURCE_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
||||||
else if( !my_markers.hasTarget() )
|
else if( !OSRM.G.markers.hasTarget() )
|
||||||
onclickGeocoderResult("target", e.latlng.lat, e.latlng.lng, true, false );
|
onclickGeocoderResult(OSRM.CONSTANTS.TARGET_LABEL, e.latlng.lat, e.latlng.lng, true, false );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ function checkURL(){
|
|||||||
|
|
||||||
// case 1: destination given
|
// case 1: destination given
|
||||||
if( destination != undefined ) {
|
if( destination != undefined ) {
|
||||||
onclickGeocoderResult("target", destination.lat, destination.lng, (destination_name == undefined) );
|
onclickGeocoderResult(OSRM.CONSTANTS.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;
|
||||||
@ -226,27 +227,27 @@ function checkURL(){
|
|||||||
if( positions != []) {
|
if( positions != []) {
|
||||||
// draw via points
|
// draw via points
|
||||||
if( positions.length > 0) {
|
if( positions.length > 0) {
|
||||||
onclickGeocoderResult("source", positions[0].lat, positions[0].lng, true, false );
|
onclickGeocoderResult(OSRM.CONSTANTS.SOURCE_LABEL, positions[0].lat, positions[0].lng, true, false );
|
||||||
//my_markers.setSource( positions[0] );
|
//OSRM.G.markers.setSource( positions[0] );
|
||||||
}
|
}
|
||||||
if(positions.length > 1) {
|
if(positions.length > 1) {
|
||||||
onclickGeocoderResult("target", positions[positions.length-1].lat, positions[positions.length-1].lng, true, false );
|
onclickGeocoderResult(OSRM.CONSTANTS.TARGET_LABEL, positions[positions.length-1].lat, positions[positions.length-1].lng, true, false );
|
||||||
//my_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++)
|
||||||
my_markers.setVia( i-1, positions[i] );
|
OSRM.G.markers.setVia( i-1, positions[i] );
|
||||||
for(var i=0; i<my_markers.route.length;i++)
|
for(var i=0; i<OSRM.G.markers.route.length;i++)
|
||||||
my_markers.route[i].show();
|
OSRM.G.markers.route[i].show();
|
||||||
|
|
||||||
// center on route (support for old links) / move to given view (new behaviour)
|
// center on route (support for old links) / move to given view (new behaviour)
|
||||||
if(zoom == null || center == null) {
|
if(zoom == null || center == null) {
|
||||||
var bounds = new L.LatLngBounds( positions );
|
var bounds = new L.LatLngBounds( positions );
|
||||||
map.fitBounds( bounds );
|
OSRM.G.map.fitBounds( bounds );
|
||||||
} else {
|
} else {
|
||||||
map.setView(center, zoom);
|
OSRM.G.map.setView(center, zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute route
|
// compute route
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,20 +20,22 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
// [TODO: major refactoring scheduled]
|
// [TODO: major refactoring scheduled]
|
||||||
|
|
||||||
// some variables
|
// some variables
|
||||||
var my_route = undefined;
|
OSRM.GLOBALS.route = null;
|
||||||
var my_markers = undefined;
|
OSRM.GLOBALS.markers = null;
|
||||||
|
|
||||||
OSRM.NO_DESCRIPTION = 0;
|
OSRM.CONSTANTS.NO_DESCRIPTION = 0;
|
||||||
OSRM.FULL_DESCRIPTION = 1;
|
OSRM.CONSTANTS.FULL_DESCRIPTION = 1;
|
||||||
OSRM.dragging = false;
|
|
||||||
OSRM.pending = false;
|
OSRM.GLOBALS.dragid = null;
|
||||||
OSRM.pendingTimer = undefined;
|
OSRM.GLOBALS.dragging = false;
|
||||||
|
OSRM.GLOBALS.pending = false;
|
||||||
|
OSRM.GLOBALS.pendingTimer = undefined;
|
||||||
|
|
||||||
|
|
||||||
// init routing data structures
|
// init routing data structures
|
||||||
function initRouting() {
|
function initRouting() {
|
||||||
my_route = new OSRM.Route();
|
OSRM.G.route = new OSRM.Route();
|
||||||
my_markers = new OSRM.Markers();
|
OSRM.G.markers = new OSRM.Markers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ function timeoutRouteSimple() {
|
|||||||
}
|
}
|
||||||
function timeoutRoute() {
|
function timeoutRoute() {
|
||||||
showNoRouteGeometry();
|
showNoRouteGeometry();
|
||||||
my_route.hideUnnamedRoute();
|
OSRM.G.route.hideUnnamedRoute();
|
||||||
showNoRouteDescription();
|
showNoRouteDescription();
|
||||||
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
||||||
}
|
}
|
||||||
@ -69,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.pending) {
|
// if(OSRM.GLOBALS.pending) {
|
||||||
// clearTimeout(OSRM.pendingTimer);
|
// clearTimeout(OSRM.GLOBALS.pendingTimer);
|
||||||
// OSRM.pendingTimer = setTimeout(timeoutDrag,100);
|
// OSRM.GLOBALS.pendingTimer = setTimeout(timeoutDrag,100);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
function showRoute(response) {
|
function showRoute(response) {
|
||||||
@ -80,7 +82,7 @@ function showRoute(response) {
|
|||||||
|
|
||||||
if(response.status == 207) {
|
if(response.status == 207) {
|
||||||
showNoRouteGeometry();
|
showNoRouteGeometry();
|
||||||
my_route.hideUnnamedRoute();
|
OSRM.G.route.hideUnnamedRoute();
|
||||||
showNoRouteDescription();
|
showNoRouteDescription();
|
||||||
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_ROUTE_FOUND")+".<p>";
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_ROUTE_FOUND")+".<p>";
|
||||||
} else {
|
} else {
|
||||||
@ -96,13 +98,13 @@ function showRoute(response) {
|
|||||||
// show route geometry
|
// show route geometry
|
||||||
function showNoRouteGeometry() {
|
function showNoRouteGeometry() {
|
||||||
var positions = [];
|
var positions = [];
|
||||||
for(var i=0; i<my_markers.route.length;i++)
|
for(var i=0; i<OSRM.G.markers.route.length;i++)
|
||||||
positions.push( my_markers.route[i].getPosition() );
|
positions.push( OSRM.G.markers.route[i].getPosition() );
|
||||||
|
|
||||||
my_route.showRoute(positions, OSRM.Route.NOROUTE);
|
OSRM.G.route.showRoute(positions, OSRM.Route.NOROUTE);
|
||||||
}
|
}
|
||||||
function showRouteGeometry(response) {
|
function showRouteGeometry(response) {
|
||||||
via_points = response.via_points.slice(0);
|
OSRM.G.via_points = response.via_points.slice(0);
|
||||||
|
|
||||||
var geometry = decodeRouteGeometry(response.route_geometry, 5);
|
var geometry = decodeRouteGeometry(response.route_geometry, 5);
|
||||||
|
|
||||||
@ -110,17 +112,17 @@ function showRouteGeometry(response) {
|
|||||||
for( var i=0; i < geometry.length; i++) {
|
for( var i=0; i < geometry.length; i++) {
|
||||||
points.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
|
points.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
|
||||||
}
|
}
|
||||||
my_route.showRoute(points, OSRM.Route.ROUTE);
|
OSRM.G.route.showRoute(points, OSRM.Route.ROUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// route description display (and helper functions)
|
// route description display (and helper functions)
|
||||||
function onClickRouteDescription(geometry_index) {
|
function onClickRouteDescription(geometry_index) {
|
||||||
var positions = my_route.getPositions();
|
var positions = OSRM.G.route.getPositions();
|
||||||
|
|
||||||
my_markers.highlight.setPosition( positions[geometry_index] );
|
OSRM.G.markers.highlight.setPosition( positions[geometry_index] );
|
||||||
my_markers.highlight.show();
|
OSRM.G.markers.highlight.show();
|
||||||
my_markers.highlight.centerView();
|
OSRM.G.markers.highlight.centerView();
|
||||||
}
|
}
|
||||||
function onClickCreateShortcut(src){
|
function onClickCreateShortcut(src){
|
||||||
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src+'&jsonp=showRouteLink', showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
|
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src+'&jsonp=showRouteLink', showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
|
||||||
@ -133,10 +135,10 @@ function showRouteLink_TimeOut(){
|
|||||||
}
|
}
|
||||||
function showRouteDescription(response) {
|
function showRouteDescription(response) {
|
||||||
// compute query string
|
// compute query string
|
||||||
var query_string = '?z='+ map.getZoom();
|
var query_string = '?z='+ OSRM.G.map.getZoom();
|
||||||
query_string += '¢er=' + map.getCenter().lat + ',' + map.getCenter().lng;
|
query_string += '¢er=' + OSRM.G.map.getCenter().lat + ',' + OSRM.G.map.getCenter().lng;
|
||||||
for(var i=0; i<my_markers.route.length; i++)
|
for(var i=0; i<OSRM.G.markers.route.length; i++)
|
||||||
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
query_string += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng();
|
||||||
|
|
||||||
// create link to the route
|
// create link to the route
|
||||||
var route_link ='<span class="route-summary" id="route-prelink">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
var route_link ='<span class="route-summary" id="route-prelink">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
||||||
@ -228,7 +230,7 @@ function showNoRouteDescription() {
|
|||||||
function showRouteNonames(response) {
|
function showRouteNonames(response) {
|
||||||
// do not display unnamed streets?
|
// do not display unnamed streets?
|
||||||
if( document.getElementById('option-highlight-nonames').checked == false) {
|
if( document.getElementById('option-highlight-nonames').checked == false) {
|
||||||
my_route.hideUnnamedRoute();
|
OSRM.G.route.hideUnnamedRoute();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +264,7 @@ function showRouteNonames(response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// display unnamed streets
|
// display unnamed streets
|
||||||
my_route.showUnnamedRoute(all_positions);
|
OSRM.G.route.showUnnamedRoute(all_positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,8 +274,8 @@ function showRouteNonames(response) {
|
|||||||
function getRoute(do_description) {
|
function getRoute(do_description) {
|
||||||
|
|
||||||
// if source or target are not set -> hide route
|
// if source or target are not set -> hide route
|
||||||
if( my_markers.route.length < 2 ) {
|
if( OSRM.G.markers.route.length < 2 ) {
|
||||||
my_route.hideRoute();
|
OSRM.G.route.hideRoute();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,13 +285,13 @@ function getRoute(do_description) {
|
|||||||
var timeout = undefined;
|
var timeout = undefined;
|
||||||
|
|
||||||
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
|
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
|
||||||
source += '?z=' + map.getZoom() + '&output=json' + '&geomformat=cmp';
|
source += '?z=' + OSRM.G.map.getZoom() + '&output=json' + '&geomformat=cmp';
|
||||||
if(my_markers.checksum)
|
if(OSRM.G.markers.checksum)
|
||||||
source += '&checksum=' + my_markers.checksum;
|
source += '&checksum=' + OSRM.G.markers.checksum;
|
||||||
for(var i=0; i<my_markers.route.length; i++) {
|
for(var i=0; i<OSRM.G.markers.route.length; i++) {
|
||||||
source += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
source += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng();
|
||||||
if( my_markers.route[i].hint)
|
if( OSRM.G.markers.route[i].hint)
|
||||||
source += '&hint=' + my_markers.route[i].hint;
|
source += '&hint=' + OSRM.G.markers.route[i].hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide whether it is a dragging call or a normal one
|
// decide whether it is a dragging call or a normal one
|
||||||
@ -310,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.pendingTimer);
|
clearTimeout(OSRM.GLOBALS.pendingTimer);
|
||||||
OSRM.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
|
OSRM.GLOBALS.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clearTimeout(OSRM.pendingTimer);
|
clearTimeout(OSRM.GLOBALS.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.pending = true;
|
// OSRM.GLOBALS.pending = true;
|
||||||
// } else {
|
// } else {
|
||||||
// clearTimeout(OSRM.pendingTimer);
|
// clearTimeout(OSRM.GLOBALS.pendingTimer);
|
||||||
// OSRM.pending = false;
|
// OSRM.GLOBALS.pending = false;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
function timeoutDrag() {
|
function timeoutDrag() {
|
||||||
my_markers.route[OSRM.dragid].hint = undefined;
|
OSRM.G.markers.route[OSRM.G.dragid].hint = undefined;
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.NO_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -362,27 +364,27 @@ function decodeRouteGeometry(encoded, precision) {
|
|||||||
// update hints of all markers
|
// update hints of all markers
|
||||||
function updateHints(response) {
|
function updateHints(response) {
|
||||||
var hint_locations = response.hint_data.locations;
|
var hint_locations = response.hint_data.locations;
|
||||||
my_markers.checksum = response.hint_data.checksum;
|
OSRM.G.markers.checksum = response.hint_data.checksum;
|
||||||
for(var i=0; i<hint_locations.length; i++)
|
for(var i=0; i<hint_locations.length; i++)
|
||||||
my_markers.route[i].hint = hint_locations[i];
|
OSRM.G.markers.route[i].hint = hint_locations[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// snap all markers to the received route
|
// snap all markers to the received route
|
||||||
function snapRoute() {
|
function snapRoute() {
|
||||||
var positions = my_route.getPositions();
|
var positions = OSRM.G.route.getPositions();
|
||||||
|
|
||||||
my_markers.route[0].setPosition( positions[0] );
|
OSRM.G.markers.route[0].setPosition( positions[0] );
|
||||||
my_markers.route[my_markers.route.length-1].setPosition( positions[positions.length-1] );
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].setPosition( positions[positions.length-1] );
|
||||||
for(var i=0; i<via_points.length; i++)
|
for(var i=0; i<OSRM.G.via_points.length; i++)
|
||||||
my_markers.route[i+1].setPosition( new L.LatLng(via_points[i][0], 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( "source" );
|
// updateLocation( OSRM.CONSTANTS.SOURCE_LABEL );
|
||||||
// updateLocation( "target" );
|
// updateLocation( OSRM.CONSTANTS.TARGET_LABEL );
|
||||||
|
|
||||||
//if(OSRM.dragid == 0 && my_markers.hasSource())
|
//if(OSRM.G.dragid == 0 && OSRM.G.markers.hasSource())
|
||||||
updateReverseGeocoder("source");
|
updateReverseGeocoder(OSRM.CONSTANTS.SOURCE_LABEL);
|
||||||
//else if(OSRM.dragid == my_markers.route.length-1 && my_markers.hasTarget())
|
//else if(OSRM.G.dragid == OSRM.G.markers.route.length-1 && OSRM.G.markers.hasTarget())
|
||||||
updateReverseGeocoder("target");
|
updateReverseGeocoder(OSRM.CONSTANTS.TARGET_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// map driving instructions to icons
|
// map driving instructions to icons
|
||||||
@ -426,9 +428,9 @@ function resetRouting() {
|
|||||||
document.getElementById('input-source-name').value = "";
|
document.getElementById('input-source-name').value = "";
|
||||||
document.getElementById('input-target-name').value = "";
|
document.getElementById('input-target-name').value = "";
|
||||||
|
|
||||||
my_route.hideAll();
|
OSRM.G.route.hideAll();
|
||||||
my_markers.removeAll();
|
OSRM.G.markers.removeAll();
|
||||||
my_markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
|
|
||||||
document.getElementById('information-box').innerHTML = "";
|
document.getElementById('information-box').innerHTML = "";
|
||||||
document.getElementById('information-box-headline').innerHTML = "";
|
document.getElementById('information-box-headline').innerHTML = "";
|
||||||
@ -444,27 +446,27 @@ function reverseRouting() {
|
|||||||
document.getElementById("input-target-name").value = tmp;
|
document.getElementById("input-target-name").value = tmp;
|
||||||
|
|
||||||
// invert route
|
// invert route
|
||||||
my_markers.route.reverse();
|
OSRM.G.markers.route.reverse();
|
||||||
if(my_markers.route.length == 1) {
|
if(OSRM.G.markers.route.length == 1) {
|
||||||
if(my_markers.route[0].label == OSRM.TARGET_MARKER_LABEL) {
|
if(OSRM.G.markers.route[0].label == OSRM.CONSTANTS.TARGET_LABEL) {
|
||||||
my_markers.route[0].label = OSRM.SOURCE_MARKER_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.SOURCE_LABEL;
|
||||||
my_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(my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
} else if(OSRM.G.markers.route[0].label == OSRM.CONSTANTS.SOURCE_LABEL) {
|
||||||
my_markers.route[0].label = OSRM.TARGET_MARKER_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.TARGET_LABEL;
|
||||||
my_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(my_markers.route.length > 1){
|
} else if(OSRM.G.markers.route.length > 1){
|
||||||
my_markers.route[0].label = OSRM.SOURCE_MARKER_LABEL;
|
OSRM.G.markers.route[0].label = OSRM.CONSTANTS.SOURCE_LABEL;
|
||||||
my_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') );
|
||||||
|
|
||||||
my_markers.route[my_markers.route.length-1].label = OSRM.TARGET_MARKER_LABEL;
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.CONSTANTS.TARGET_LABEL;
|
||||||
my_markers.route[my_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( my_route.isShown() ) {
|
if( OSRM.G.route.isShown() ) {
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
my_markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('information-box').innerHTML = "";
|
document.getElementById('information-box').innerHTML = "";
|
||||||
document.getElementById('information-box-headline').innerHTML = "";
|
document.getElementById('information-box-headline').innerHTML = "";
|
||||||
@ -473,9 +475,9 @@ function reverseRouting() {
|
|||||||
|
|
||||||
// click: button "show"
|
// click: button "show"
|
||||||
function centerMarker(marker_id) {
|
function centerMarker(marker_id) {
|
||||||
if( marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.hasSource() && !my_markers.route[0].dirty_type ) {
|
if( marker_id == OSRM.CONSTANTS.SOURCE_LABEL && OSRM.G.markers.hasSource() && !OSRM.G.markers.route[0].dirty_type ) {
|
||||||
my_markers.route[0].centerView();
|
OSRM.G.markers.route[0].centerView();
|
||||||
} else if( marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.hasTarget() && !my_markers.route[my_markers.route.length-1].dirty_type) {
|
} else if( marker_id == OSRM.CONSTANTS.TARGET_LABEL && OSRM.G.markers.hasTarget() && !OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type) {
|
||||||
my_markers.route[my_markers.route.length-1].centerView();
|
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// store location of via points returned by server
|
// store location of via points returned by server
|
||||||
var via_points;
|
OSRM.GLOBALS.via_points = null;
|
||||||
|
|
||||||
|
|
||||||
// find route segment of current route geometry that is closest to the new via node (marked by index of its endpoint)
|
// find route segment of current route geometry that is closest to the new via node (marked by index of its endpoint)
|
||||||
@ -24,7 +24,7 @@ function findNearestRouteSegment( new_via ) {
|
|||||||
var min_dist = Number.MAX_VALUE;
|
var min_dist = Number.MAX_VALUE;
|
||||||
var min_index = undefined;
|
var min_index = undefined;
|
||||||
|
|
||||||
var positions = my_route.getPositions();
|
var positions = OSRM.G.route.getPositions();
|
||||||
for(var i=0; i<positions.length-1; i++) {
|
for(var i=0; i<positions.length-1; i++) {
|
||||||
var dist = dotLineLength( new_via.lng, new_via.lat, positions[i].lng, positions[i].lat, positions[i+1].lng, positions[i+1].lat, true);
|
var dist = dotLineLength( new_via.lng, new_via.lat, positions[i].lng, positions[i].lat, positions[i+1].lng, positions[i+1].lat, true);
|
||||||
if( dist < min_dist) {
|
if( dist < min_dist) {
|
||||||
@ -43,10 +43,10 @@ function findViaPosition( new_via_position ) {
|
|||||||
var nearest_index = findNearestRouteSegment( new_via_position );
|
var nearest_index = findNearestRouteSegment( new_via_position );
|
||||||
|
|
||||||
// find correct index to insert new via node
|
// find correct index to insert new via node
|
||||||
var new_via_index = via_points.length;
|
var new_via_index = OSRM.G.via_points.length;
|
||||||
var via_index = Array();
|
var via_index = Array();
|
||||||
for(var i=0; i<via_points.length; i++) {
|
for(var i=0; i<OSRM.G.via_points.length; i++) {
|
||||||
via_index[i] = findNearestRouteSegment( new L.LatLng(via_points[i][0], via_points[i][1]) );
|
via_index[i] = findNearestRouteSegment( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
|
||||||
if(via_index[i] > nearest_index) {
|
if(via_index[i] > nearest_index) {
|
||||||
new_via_index = i;
|
new_via_index = i;
|
||||||
break;
|
break;
|
||||||
@ -54,10 +54,10 @@ function findViaPosition( new_via_position ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add via node
|
// add via node
|
||||||
var index = my_markers.setVia(new_via_index, new_via_position);
|
var index = OSRM.G.markers.setVia(new_via_index, new_via_position);
|
||||||
my_markers.route[index].show();
|
OSRM.G.markers.route[index].show();
|
||||||
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.CONSTANTS.FULL_DESCRIPTION);
|
||||||
|
|
||||||
return new_via_index;
|
return new_via_index;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user