Pre-fill directions 'from' field with search query, if any.
This commit is contained in:
parent
c3e2e6462f
commit
9995d316b2
2 changed files with 14 additions and 0 deletions
|
@ -290,6 +290,10 @@ OSM.Directions = function (map) {
|
|||
setEngine(params.engine);
|
||||
}
|
||||
|
||||
if (params.from) {
|
||||
$(".directions_form input[name='route_from']").val(params.from);
|
||||
}
|
||||
|
||||
var o = route[0] && L.latLng(route[0].split(',')),
|
||||
d = route[1] && L.latLng(route[1].split(','));
|
||||
|
||||
|
|
|
@ -9,6 +9,16 @@ OSM.Search = function(map) {
|
|||
}
|
||||
});
|
||||
|
||||
$(".search_form a.button.switch_link").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
var query = $(e.target).parent().parent().find("input[name=query]").val();
|
||||
if (query) {
|
||||
OSM.router.route("/directions?from=" + encodeURIComponent(query) + OSM.formatHash(map));
|
||||
} else {
|
||||
OSM.router.route("/directions" + OSM.formatHash(map));
|
||||
}
|
||||
});
|
||||
|
||||
$(".search_form").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
$("header").addClass("closed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue