2020-12-14 00:27:49 +00:00
|
|
|
import {Marker} from "leaflet";
|
|
|
|
import {DynmapMarker} from "@/dynmap";
|
|
|
|
import {DynmapIcon} from "@/leaflet/icon/DynmapIcon";
|
|
|
|
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
|
2020-12-14 15:48:58 +00:00
|
|
|
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
|
2020-12-14 00:27:49 +00:00
|
|
|
|
|
|
|
export const createMarker = (options: DynmapMarker, projection: DynmapProjection): Marker => {
|
2020-12-14 15:48:58 +00:00
|
|
|
return new GenericMarker(projection.locationToLatLng(options.location), {
|
2020-12-14 00:27:49 +00:00
|
|
|
icon: new DynmapIcon({
|
|
|
|
icon: options.icon,
|
|
|
|
label: options.label,
|
|
|
|
iconSize: options.dimensions,
|
|
|
|
showLabel: false,
|
|
|
|
isHtml: options.isHTML,
|
|
|
|
}),
|
|
|
|
// maxZoom: this.options.maxZoom,
|
|
|
|
// minZoom: this.options.minZoom,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const updateMarker = (marker: Marker | undefined, options: DynmapMarker, projection: DynmapProjection): Marker => {
|
|
|
|
if (!marker) {
|
|
|
|
return createMarker(options, projection);
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
return marker;
|
|
|
|
};
|