Pan slowly on click on the nuisance map

This commit is contained in:
Eli Ribble 2026-02-03 17:22:32 +00:00
parent 82adb92d06
commit 8bed4fa2fa
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

View file

@ -125,12 +125,12 @@ class MapLocator extends HTMLElement {
this._map.jumpTo(args);
}
PanTo(coords, options) {
this._map.panTo(coords, options);
}
SetMarker(coords) {
console.log("Setting map marker", coords);
this._map.jumpTo({
center: coords,
zoom: 14,
});
this._markers.forEach((marker) => marker.remove());
const marker = new mapboxgl.Marker({

View file

@ -12,6 +12,7 @@
const MAPBOX_ACCESS_TOKEN = "{{.MapboxToken}}";
async function handleMapClick(mapLocator, lngLat) {
mapLocator.SetMarker(lngLat);
mapLocator.PanTo(lngLat, {duration: 2000});
const response = await geocodeReverse(MAPBOX_ACCESS_TOKEN, {
lat: lngLat.lat,
lng: lngLat.lng,
@ -115,10 +116,12 @@ document.addEventListener('DOMContentLoaded', function() {
},
zoom: 14,
});
mapLocator.SetMarker([
const coords = [
position.coords.longitude,
position.coords.latitude,
]);
];
mapLocator.SetMarker(coords);
mapLocator.JumpTo({center: coords, zoom: 14});
handleMarkerDrag({
lat: position.coords.latitude,
lng: position.coords.longitude,