Fix marker updates when projection changes

This commit is contained in:
James Lyne 2020-12-16 11:59:09 +00:00
parent 2000f8f5e9
commit 43a15e575f

View File

@ -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;
};
};