@tomhughes commented on this pull request.
> + if (!map) return;
+
+ const point = map.project(this.getLngLat()),
+ { clientWidth, clientHeight } = map.getContainer();
+
+ let dx = 0,
+ dy = 0;
+ if (point.x < edgeDistance) dx = point.x - edgeDistance;
+ else if (point.x > clientWidth - edgeDistance) dx = point.x -
(clientWidth - edgeDistance);
+ if (point.y < edgeDistance) dy = point.y - edgeDistance;
+ else if (point.y > clientHeight - edgeDistance) dy = point.y -
(clientHeight - edgeDistance);
+ if (!dx && !dy) return;
+
+ const clamp = (v) => Math.max(-maxPanStep, Math.min(maxPanStep, v));
+ map.panBy([clamp(dx), clamp(dy)], { duration: 0 });
+ this.setLngLat(map.unproject(point));
Why do we need to set the marker location when it hasn't changed? Is the issue
that the marker is really at a fixed X/Y position in the viewport and by
panning the map that has got out of sync with the lat/lon and this forces it to
be recomputed?
> +
+ const point = map.project(this.getLngLat()),
+ { clientWidth, clientHeight } = map.getContainer();
+
+ let dx = 0,
+ dy = 0;
+ if (point.x < edgeDistance) dx = point.x - edgeDistance;
+ else if (point.x > clientWidth - edgeDistance) dx = point.x -
(clientWidth - edgeDistance);
+ if (point.y < edgeDistance) dy = point.y - edgeDistance;
+ else if (point.y > clientHeight - edgeDistance) dy = point.y -
(clientHeight - edgeDistance);
+ if (!dx && !dy) return;
+
+ const clamp = (v) => Math.max(-maxPanStep, Math.min(maxPanStep, v));
+ map.panBy([clamp(dx), clamp(dy)], { duration: 0 });
+ this.setLngLat(map.unproject(point));
+ this.fire("drag");
Why do we need to fire an event here? Because the previous line may have moved
the marker in X/Y space even it not in lat/lon space?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7188#pullrequestreview-4587723089
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/7188/review/[email protected]>_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev