autoPan: true
});
- endpoint.marker.on("drag dragend", function (e) {
+ endpoint.enable = function () {
+ endpoint.marker.on("drag dragend", markerDragListener);
+ input.on("keydown", inputKeydownListener);
+ input.on("change", inputChangeListener);
+ };
+
+ endpoint.disable = function () {
+ endpoint.marker.off("drag dragend", markerDragListener);
+ input.off("keydown", inputKeydownListener);
+ input.off("change", inputChangeListener);
+ };
+
+ function markerDragListener(e) {
var latlng = e.target.getLatLng();
setLatLng(latlng);
setInputValueFromLatLng(latlng);
endpoint.value = input.val();
dragCallback(e.type === "drag");
- });
+ }
- input.on("keydown", function () {
+ function inputKeydownListener() {
input.removeClass("is-invalid");
- });
+ }
- input.on("change", function (e) {
+ function inputChangeListener(e) {
// make text the same in both text boxes
var value = e.target.value;
endpoint.setValue(value);
- });
+ }
endpoint.setValue = function (value, latlng) {
endpoint.value = value;
endpoints[type === "from" ? 0 : 1].setValue(value, ll);
});
+ 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(",")),
$(".directions_form").hide();
$("#map").off("dragend dragover drop");
+ endpoints[0].disable();
+ endpoints[1].disable();
+
map
.removeLayer(popup)
.removeLayer(polyline)