Prevent exceptions while reversing directions

This commit is contained in:
Holger Jeromin 2020-01-26 11:01:45 +01:00 committed by GitHub
parent ac3df158f7
commit a32f4c231e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -142,12 +142,20 @@ OSM.Directions = function (map) {
$(".directions_form .reverse_directions").on("click", function () { $(".directions_form .reverse_directions").on("click", function () {
var from = endpoints[0].latlng, var from = endpoints[0].latlng,
to = endpoints[1].latlng; to = endpoints[1].latlng,
routeFrom = "",
routeTo = "";
if(from){
routeFrom = from.lat + "," + from.lng;
}
if(to){
routeTo = to.lat + "," + to.lng;
}
OSM.router.route("/directions?" + querystring.stringify({ OSM.router.route("/directions?" + querystring.stringify({
from: $("#route_to").val(), from: $("#route_to").val(),
to: $("#route_from").val(), to: $("#route_from").val(),
route: to.lat + "," + to.lng + ";" + from.lat + "," + from.lng route: routeTo + ";" + routeFrom
})); }));
}); });