restructured for release
@ -23,10 +23,6 @@ OSRM.JSONP = {
|
|||||||
|
|
||||||
// wrap timeout function
|
// wrap timeout function
|
||||||
OSRM.JSONP.timeouts[id] = function(response) {
|
OSRM.JSONP.timeouts[id] = function(response) {
|
||||||
if( OSRM.JSONP.fences[id] == undefined ){ // fence to prevent execution after timeout function (when precompiled!)
|
|
||||||
//OSRM.debug.log("x");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timeout_function(response);
|
timeout_function(response);
|
||||||
|
|
||||||
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
||||||
@ -45,10 +41,8 @@ OSRM.JSONP = {
|
|||||||
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
||||||
OSRM.JSONP.timers[id] = undefined;
|
OSRM.JSONP.timers[id] = undefined;
|
||||||
|
|
||||||
if( OSRM.JSONP.fences[id] == undefined ){ // fence to prevent execution after timeout function (when precompiled!)
|
if( OSRM.JSONP.fences[id] == undefined ) // fence to prevent execution after timeout function (when precompiled!)
|
||||||
//OSRM.debug.log("y");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
callback_function(response); // actual wrapped callback
|
callback_function(response); // actual wrapped callback
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ 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 = map.getZoom();
|
||||||
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-0.02), zoom); // dirty hack
|
||||||
|
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+")";
|
||||||
@ -94,8 +95,8 @@ onDrag: function(e) {
|
|||||||
this.parent.setPosition( e.target.getLatLng() );
|
this.parent.setPosition( e.target.getLatLng() );
|
||||||
if(OSRM.dragging == true) // TODO: hack to deal with drag events after dragend event
|
if(OSRM.dragging == true) // TODO: hack to deal with drag events after dragend event
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
// else
|
else
|
||||||
// getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,15 @@ function updateLocation(marker_id) {
|
|||||||
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 = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function updateReverseGeocoder(marker_id) {
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
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);
|
||||||
|
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
function updateLocations() {
|
function updateLocations() {
|
||||||
if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
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 = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
@ -78,6 +87,7 @@ function callGeocoder(marker_id, query) {
|
|||||||
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
|
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
|
||||||
var coord = query.split(/[,;]/);
|
var coord = query.split(/[,;]/);
|
||||||
onclickGeocoderResult(marker_id, coord[0], coord[1]);
|
onclickGeocoderResult(marker_id, coord[0], coord[1]);
|
||||||
|
// updateReverseGeocoder(marker_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 440 B |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 669 B After Width: | Height: | Size: 617 B |
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.6 KiB |
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<script src="OSRM.base.js" type="text/javascript"></script>
|
<script src="OSRM.base.js" type="text/javascript"></script>
|
||||||
<script src="OSRM.config.js" type="text/javascript"></script>
|
<script src="OSRM.config.js" type="text/javascript"></script>
|
||||||
<script defer="defer" src="OSRM.debug.js" type="text/javascript"></script>
|
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
|
||||||
|
|
||||||
<script src="OSRM.Browser.js" type="text/javascript"></script>
|
<script src="OSRM.Browser.js" type="text/javascript"></script>
|
||||||
<script src="OSRM.GUI.js" type="text/javascript"></script>
|
<script src="OSRM.GUI.js" type="text/javascript"></script>
|
||||||
|
@ -17,10 +17,10 @@ function init() {
|
|||||||
// prefetch images
|
// prefetch images
|
||||||
OSRM.images = Array();
|
OSRM.images = Array();
|
||||||
function prefetchImages() {
|
function prefetchImages() {
|
||||||
var images = [ 'http://map.project-osrm.org/new/images/marker-source.png',
|
var images = [ 'images/marker-source.png',
|
||||||
'http://map.project-osrm.org/new/images/marker-target.png',
|
'images/marker-target.png',
|
||||||
'http://map.project-osrm.org/new/images/marker-via.png',
|
'images/marker-via.png',
|
||||||
'http://map.project-osrm.org/new/images/marker-highlight.png'
|
'images/marker-highlight.png'
|
||||||
];
|
];
|
||||||
|
|
||||||
for(var i=0; i<images.length; i++) {
|
for(var i=0; i<images.length; i++) {
|
||||||
@ -40,7 +40,7 @@ function prefetchIcons() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for(var i=0; i<images.length; i++)
|
for(var i=0; i<images.length; i++)
|
||||||
OSRM.icons[images[i]] = new L.Icon('http://map.project-osrm.org/new/images/'+images[i]+'.png');
|
OSRM.icons[images[i]] = new L.Icon('images/'+images[i]+'.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,12 +128,16 @@ function initMap() {
|
|||||||
my_markers.route[index].show();
|
my_markers.route[index].show();
|
||||||
my_markers.route[index].centerView(false);
|
my_markers.route[index].centerView(false);
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
updateLocation("source");
|
||||||
|
// updateReverseGeocoder("source");
|
||||||
}
|
}
|
||||||
else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
|
else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
|
||||||
index = my_markers.setTarget( e.latlng );
|
index = my_markers.setTarget( e.latlng );
|
||||||
my_markers.route[index].show();
|
my_markers.route[index].show();
|
||||||
my_markers.route[index].centerView(false);
|
my_markers.route[index].centerView(false);
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
updateLocation("target");
|
||||||
|
// updateReverseGeocoder("target");
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
// onmousemove test
|
// onmousemove test
|
||||||
@ -203,7 +207,7 @@ function checkURL(){
|
|||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
var bounds = new L.LatLngBounds( positions );
|
var bounds = new L.LatLngBounds( positions );
|
||||||
bounds._southWest.lng-=1.02; // dirty hacks
|
//bounds._southWest.lng-=1.02; // dirty hacks
|
||||||
map.fitBounds( bounds );
|
map.fitBounds( bounds );
|
||||||
//my_route.centerView();
|
//my_route.centerView();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,6 @@ function showRoute(response) {
|
|||||||
snapRoute();
|
snapRoute();
|
||||||
}
|
}
|
||||||
updateHints(response);
|
updateHints(response);
|
||||||
updateLocations();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoRouteGeometry() {
|
function showNoRouteGeometry() {
|
||||||
@ -314,7 +313,6 @@ function getRoute(do_description) {
|
|||||||
function timeoutDrag() {
|
function timeoutDrag() {
|
||||||
my_markers.route[OSRM.dragid].hint = undefined;
|
my_markers.route[OSRM.dragid].hint = undefined;
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
// OSRM.debug.log("timer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function startRouting() {
|
function startRouting() {
|
||||||
|