[openstreetmap/openstreetmap-website] Fixed displacing points specified from context menu (PR #4904)

Anton Khorev notifications at github.com
Tue Aug 20 11:39:17 UTC 2024


@AntonKhorev commented on this pull request.



> -        endpoint.setLatLng(L.latLng(json[0]));
+      if (endpoint.value.match(new RegExp("^" + coordinatesRegularExpression + "$"))) {
+        var latlng_array = endpoint.value.split(/[/,]/);
+        $.getJSON(OSM.NOMINATIM_URL + "reverse?lat=" + latlng_array[0] + "&lon=" + latlng_array[1] + "&format=json&viewbox=" + viewbox, function (json) {
+          endpoint.awaitingGeocode = false;
+          endpoint.hasGeocode = true;
+
+          endpoint.setLatLng(L.latLng(latlng_array), false, true);
+
+          if (!json || !json.display_name) {
+            input.addClass("is-invalid");
+            alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
+            return;
+          }
+
+          if (endpoint.latlng.distanceTo(L.latLng(json.lat, json.lon)) > 200.0) {

What was this distance check about? Was it to filter out useless reverse geocoding results that are too far away from the endpoint?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4904#pullrequestreview-2247752954
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4904/review/2247752954 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240820/edf3f776/attachment-0001.htm>


More information about the rails-dev mailing list