X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/93a9f31bf0e1cd3d5aec478aeef65c8132b02bdd..a1051b418e7a838e5dc14f8491f97de5510d1437:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index ff76f4008..df5677105 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -65,10 +65,9 @@ OSM.Directions = function (map) { if (coordTo) { routeTo = coordTo.lat + "," + coordTo.lng; } + endpoints[0].swapCachedReverseGeocodes(endpoints[1]); OSM.router.route("/directions?" + Qs.stringify({ - from: $("#route_to").val(), - to: $("#route_from").val(), route: routeTo + ";" + routeFrom })); }); @@ -287,13 +286,14 @@ OSM.Directions = function (map) { var ll = map.containerPointToLatLng(pt); var precision = OSM.zoomPrecision(map.getZoom()); var value = ll.lat.toFixed(precision) + ", " + ll.lng.toFixed(precision); - endpoints[type === "from" ? 0 : 1].setValue(value, ll); + endpoints[type === "from" ? 0 : 1].setValue(value); }); + endpoints[0].enable(); + endpoints[1].enable(); + var params = Qs.parse(location.search.substring(1)), - route = (params.route || "").split(";"), - from = route[0] && L.latLng(route[0].split(",")), - to = route[1] && L.latLng(route[1].split(",")); + route = (params.route || "").split(";"); if (params.engine) { var engineIndex = findEngine(params.engine); @@ -303,10 +303,10 @@ OSM.Directions = function (map) { } } - endpoints[0].setValue(params.from || "", from); - endpoints[1].setValue(params.to || "", to); + endpoints[0].setValue(params.from || route[0] || ""); + endpoints[1].setValue(params.to || route[1] || ""); - map.setSidebarOverlaid(!from || !to); + map.setSidebarOverlaid(!endpoints[0].latlng || !endpoints[1].latlng); }; page.load = function () { @@ -318,11 +318,12 @@ OSM.Directions = function (map) { $(".directions_form").hide(); $("#map").off("dragend dragover drop"); + endpoints[0].disable(); + endpoints[1].disable(); + map .removeLayer(popup) - .removeLayer(polyline) - .removeLayer(endpoints[0].marker) - .removeLayer(endpoints[1].marker); + .removeLayer(polyline); }; return page;