From 43a15e575ff4b8b2fc9ebd4e7c6e5237f013e472 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 16 Dec 2020 11:59:09 +0000 Subject: [PATCH] Fix marker updates when projection changes --- src/util/markers.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/markers.ts b/src/util/markers.ts index 1b3a26f..cc0c703 100644 --- a/src/util/markers.ts +++ b/src/util/markers.ts @@ -1,4 +1,4 @@ -import {Marker} from "leaflet"; +import {LatLng, Marker} from "leaflet"; import {DynmapMarker} from "@/dynmap"; import {DynmapIcon} from "@/leaflet/icon/DynmapIcon"; import {DynmapProjection} from "@/leaflet/projection/DynmapProjection"; @@ -23,7 +23,12 @@ export const updateMarker = (marker: Marker | undefined, options: DynmapMarker, return createMarker(options, projection); } - //TODO + const oldLocation = marker.getLatLng(), + newLocation = projection.locationToLatLng(options.location); + + if(!oldLocation.equals(newLocation)) { + marker.setLatLng(newLocation); + } return marker; -}; \ No newline at end of file +};