[openstreetmap/openstreetmap-website] Delete button in Home location section of user profiles (PR #4149)

Tom Hughes notifications at github.com
Fri Aug 11 17:08:40 UTC 2023


@tomhughes commented on this pull request.



> +    $("#home_delete").prop("hidden", !location);
+    $("#home_undelete").prop("hidden", !(!location && deleted_lat && deleted_lon));
+    if (location) {
+      marker.setLatLng([lat, lon]);
+      marker.addTo(map);
+      map.panTo([lat, lon]);
+    } else {
+      marker.removeFrom(map);
+    }
+  }
+
+  function isCloseEnoughToMapCenter(location) {
+    var inputPt = map.latLngToContainerPoint(location),
+        centerPt = map.latLngToContainerPoint(map.getCenter());
+
+    return Math.abs(inputPt.x - centerPt.x) + Math.abs(inputPt.y - centerPt.y) < 10;

Would `distanceTo` work here to get the distance between two points? or just use `map.getBounds().contains(location)` to see if the location is already visible?

> -          var zoom = map.getZoom(),
-              precision = OSM.zoomPrecision(zoom),
-              location = e.latlng.wrap();
+        if (!$("#updatehome").is(":checked")) return;
+
+        var zoom = map.getZoom(),
+            precision = OSM.zoomPrecision(zoom),
+            location = e.latlng.wrap();
+
+        $("#home_lat").val(location.lat.toFixed(precision));
+        $("#home_lon").val(location.lng.toFixed(precision));
+
+        deleted_lat = null;
+        deleted_lon = null;
+        respondToHomeUpdate();
+      }).on("moveend", function () {

Why are we using a `moveend` event to detect typed changes in the input fields? At least I assume that is what this is trying to detect given we already have a click handler....

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

Message ID: <openstreetmap/openstreetmap-website/pull/4149/review/1574084723 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230811/8c3d224e/attachment.htm>


More information about the rails-dev mailing list