endpoint.setValue(value);
}
- endpoint.setValue = function (value, latlng) {
+ endpoint.setValue = function (value) {
endpoint.value = value;
removeLatLng();
input.removeClass("is-invalid");
if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort();
delete endpoint.geocodeRequest;
+ var coordinatesMatch = value.match(/^\s*([+-]?\d+(?:\.\d*)?)(?:\s+|\s*[/,]\s*)([+-]?\d+(?:\.\d*)?)\s*$/);
+ var latlng = coordinatesMatch && L.latLng(coordinatesMatch[1], coordinatesMatch[2]);
+
if (latlng) {
setLatLng(latlng);
setInputValueFromLatLng(latlng);
var ll = map.containerPointToLatLng(pt);
var precision = OSM.zoomPrecision(map.getZoom());
var value = ll.lat.toFixed(precision) + ", " + ll.lng.toFixed(precision);
- var llWithPrecision = L.latLng(ll.lat.toFixed(precision), ll.lng.toFixed(precision));
- endpoints[type === "from" ? 0 : 1].setValue(value, llWithPrecision);
+ 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);
}
}
- 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 () {