added support for saving route zoom level and position in route links
This commit is contained in:
parent
d86eaa00a0
commit
9567a7e38c
@ -176,8 +176,10 @@ function checkURL(){
|
|||||||
|
|
||||||
// storage for parameter values
|
// storage for parameter values
|
||||||
var positions = [];
|
var positions = [];
|
||||||
var destination = undefined;
|
var zoom = null;
|
||||||
var destination_name = undefined;
|
var center = null;
|
||||||
|
var destination = null;
|
||||||
|
var destination_name = null;
|
||||||
|
|
||||||
// parse input
|
// parse input
|
||||||
var splitted_url = called_url.split('&');
|
var splitted_url = called_url.split('&');
|
||||||
@ -201,6 +203,17 @@ function checkURL(){
|
|||||||
else if(name_val[0] == 'destname') {
|
else if(name_val[0] == 'destname') {
|
||||||
destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags
|
destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags
|
||||||
}
|
}
|
||||||
|
else if(name_val[0] == 'zoom') {
|
||||||
|
zoom = name_val[1];
|
||||||
|
if( zoom<0 || zoom > 18)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(name_val[0] == 'center') {
|
||||||
|
var coordinates = unescape(name_val[1]).split(',');
|
||||||
|
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
|
||||||
|
return;
|
||||||
|
center = new L.LatLng( coordinates[0], coordinates[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// case 1: destination given
|
// case 1: destination given
|
||||||
@ -227,9 +240,13 @@ function checkURL(){
|
|||||||
for(var i=0; i<my_markers.route.length;i++)
|
for(var i=0; i<my_markers.route.length;i++)
|
||||||
my_markers.route[i].show();
|
my_markers.route[i].show();
|
||||||
|
|
||||||
// center on route
|
// center on route (support for old links) / move to given view (new behaviour)
|
||||||
var bounds = new L.LatLngBounds( positions );
|
if(zoom == null || center == null) {
|
||||||
map.fitBounds( bounds );
|
var bounds = new L.LatLngBounds( positions );
|
||||||
|
map.fitBounds( bounds );
|
||||||
|
} else {
|
||||||
|
map.setView(center, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
// compute route
|
// compute route
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
@ -134,6 +134,7 @@ 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='+ map.getZoom();
|
||||||
|
query_string += '¢er=' + map.center.getLat() + ',' + map.center.getLng();
|
||||||
for(var i=0; i<my_markers.route.length; i++)
|
for(var i=0; i<my_markers.route.length; i++)
|
||||||
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user