Merge remote-tracking branch 'upstream/pull/5634'
This commit is contained in:
commit
97bd4579b0
3 changed files with 15 additions and 18 deletions
|
@ -101,8 +101,8 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
|
|||
};
|
||||
|
||||
function getGeocode() {
|
||||
var viewbox = map.getBounds().toBBoxString(); // <sw lon>,<sw lat>,<ne lon>,<ne lat>
|
||||
var geocodeUrl = OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox;
|
||||
const viewbox = map.getBounds().toBBoxString(), // <sw lon>,<sw lat>,<ne lon>,<ne lat>
|
||||
geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox });
|
||||
|
||||
endpoint.geocodeRequest = $.getJSON(geocodeUrl, function (json) {
|
||||
delete endpoint.geocodeRequest;
|
||||
|
@ -123,8 +123,9 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
|
|||
}
|
||||
|
||||
function getReverseGeocode() {
|
||||
var latlng = endpoint.latlng.clone();
|
||||
var reverseGeocodeUrl = OSM.NOMINATIM_URL + "reverse?lat=" + latlng.lat + "&lon=" + latlng.lng + "&format=json";
|
||||
const latlng = endpoint.latlng.clone(),
|
||||
{ lat, lng } = latlng,
|
||||
reverseGeocodeUrl = OSM.NOMINATIM_URL + "reverse?" + new URLSearchParams({ lat, lon: lng, format: "json" });
|
||||
|
||||
endpoint.geocodeRequest = $.getJSON(reverseGeocodeUrl, function (json) {
|
||||
delete endpoint.geocodeRequest;
|
||||
|
|
|
@ -10,22 +10,18 @@ OSM.Search = function (map) {
|
|||
$(".search_form a.btn.switch_link").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var query = $(this).closest("form").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));
|
||||
}
|
||||
let search = "";
|
||||
if (query) search = "?" + new URLSearchParams({ from: query });
|
||||
OSM.router.route("/directions" + search + OSM.formatHash(map));
|
||||
});
|
||||
|
||||
$(".search_form").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
$("header").addClass("closed");
|
||||
var query = $(this).find("input[name=query]").val();
|
||||
if (query) {
|
||||
OSM.router.route("/search?query=" + encodeURIComponent(query) + OSM.formatHash(map));
|
||||
} else {
|
||||
OSM.router.route("/" + OSM.formatHash(map));
|
||||
}
|
||||
let search = "/";
|
||||
if (query) search = "/search?" + new URLSearchParams({ query });
|
||||
OSM.router.route(search + OSM.formatHash(map));
|
||||
});
|
||||
|
||||
$(".describe_location").on("click", function (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue