From e3233e3dfa58d0181a4f577d50a55e6d4579dae3 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Tue, 25 May 2021 23:31:03 +0100 Subject: [PATCH] Pan on marker click --- src/util/markers.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/markers.ts b/src/util/markers.ts index bf48a30..30ce92f 100644 --- a/src/util/markers.ts +++ b/src/util/markers.ts @@ -17,7 +17,7 @@ * limitations under the License. */ -import {Marker} from "leaflet"; +import {LeafletMouseEvent, Marker} from "leaflet"; import {DynmapMarker} from "@/dynmap"; import {DynmapIcon} from "@/leaflet/icon/DynmapIcon"; import {DynmapProjection} from "@/leaflet/projection/DynmapProjection"; @@ -35,6 +35,10 @@ export const createMarker = (options: DynmapMarker, projection: DynmapProjection minZoom: options.minZoom, }); + marker.on('click', (e: LeafletMouseEvent) => { + e.target._map.panTo(e.target.getLatLng()); + }); + if(options.popupContent) { marker.bindPopup(() => createPopup(options)); }