LiveAtlas/src/util/markers.ts

29 lines
885 B
TypeScript
Raw Normal View History

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";
export const createMarker = (options: DynmapMarker, projection: DynmapProjection): Marker => {
2020-12-14 15:48:58 +00:00
return new GenericMarker(projection.locationToLatLng(options.location), {
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;
};