diff --git a/src/components/map/layer/MarkerSetLayer.vue b/src/components/map/layer/MarkerSetLayer.vue
index f9cb8c3..2857d55 100644
--- a/src/components/map/layer/MarkerSetLayer.vue
+++ b/src/components/map/layer/MarkerSetLayer.vue
@@ -15,30 +15,21 @@
-->
-
-
-
-
+
diff --git a/src/components/map/vector/Circles.vue b/src/components/map/vector/Circles.vue
deleted file mode 100644
index 7b7e2e5..0000000
--- a/src/components/map/vector/Circles.vue
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
diff --git a/src/components/map/vector/Lines.vue b/src/components/map/vector/Lines.vue
deleted file mode 100644
index 3f4ef29..0000000
--- a/src/components/map/vector/Lines.vue
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
diff --git a/src/index.d.ts b/src/index.d.ts
index b5d5b19..d74af6b 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -22,6 +22,7 @@ import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
import {globalMessages, serverMessages} from "../messages";
+import {LiveAtlasMarkerType} from "@/util/markers";
declare module "*.png" {
const value: any;
@@ -178,14 +179,9 @@ interface LiveAtlasMarkerSet {
showLabels?: boolean;
}
-interface LiveAtlasMarkerSetContents {
- points: Map,
- areas: Map;
- lines: Map;
- circles: Map;
-}
-
interface LiveAtlasMarker {
+ id: string;
+ type: LiveAtlasMarkerType;
tooltip: string;
tooltipHTML?: string;
popup?: string;
@@ -196,6 +192,7 @@ interface LiveAtlasMarker {
}
interface LiveAtlasPointMarker extends LiveAtlasMarker {
+ type: LiveAtlasMarkerType.POINT;
dimensions: PointTuple;
icon: string;
}
@@ -204,20 +201,21 @@ interface LiveAtlasPathMarker extends LiveAtlasMarker {
style: PathOptions;
}
-interface LiveAtlasAreaMarker extends LiveAtlasPathMarker {
- style: PolylineOptions;
- outline: boolean;
- points: Coordinate[] | Coordinate[][] | Coordinate[][][]
-}
-
interface LiveAtlasLineMarker extends LiveAtlasPathMarker {
+ type: LiveAtlasMarkerType.LINE;
points: Coordinate[];
style: PolylineOptions;
}
+interface LiveAtlasAreaMarker extends LiveAtlasLineMarker {
+ type: LiveAtlasMarkerType.AREA;
+ outline: boolean;
+ points: Coordinate[] | Coordinate[][] | Coordinate[][][];
+}
+
interface LiveAtlasCircleMarker extends LiveAtlasPathMarker {
+ type: LiveAtlasMarkerType.CIRCLE;
radius: PointTuple;
- style: PathOptions;
}
interface HeadQueueEntry {
diff --git a/src/providers/DynmapMapProvider.ts b/src/providers/DynmapMapProvider.ts
index 22a2c9f..0c8e2fb 100644
--- a/src/providers/DynmapMapProvider.ts
+++ b/src/providers/DynmapMapProvider.ts
@@ -15,8 +15,8 @@
*/
import {
- HeadQueueEntry,
- LiveAtlasMarkerSet, LiveAtlasMarkerSetContents,
+ HeadQueueEntry, LiveAtlasMarker,
+ LiveAtlasMarkerSet,
LiveAtlasPlayer,
LiveAtlasServerDefinition,
LiveAtlasWorldDefinition
@@ -48,7 +48,7 @@ export default class DynmapMapProvider extends MapProvider {
private updateInterval: number = 3000;
private markerSets: Map = new Map();
- private markers = new Map();
+ private markers = new Map>();
constructor(config: LiveAtlasServerDefinition) {
super(config);
@@ -73,15 +73,16 @@ export default class DynmapMapProvider extends MapProvider {
}
const set: MarkerSet = response.sets[key],
- markerSet = buildMarkerSet(key, set);
+ markerSet = buildMarkerSet(key, set),
+ markers = new Map();
+
+ buildMarkers(set.markers || {}, markers);
+ buildAreas(set.areas || {}, markers);
+ buildLines(set.lines || {}, markers);
+ buildCircles(set.circles || {}, markers);
this.markerSets.set(key, markerSet);
- this.markers.set(key, Object.seal({
- points: buildMarkers(set.markers || {}),
- areas: buildAreas(set.areas || {}),
- lines: buildLines(set.lines || {}),
- circles: buildCircles(set.circles || {}),
- }));
+ this.markers.set(key, markers);
}
}
diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts
index b759467..4c19c20 100644
--- a/src/providers/Pl3xmapMapProvider.ts
+++ b/src/providers/Pl3xmapMapProvider.ts
@@ -20,11 +20,11 @@ import {
LiveAtlasCircleMarker,
LiveAtlasComponentConfig,
LiveAtlasDimension,
- LiveAtlasLineMarker,
- LiveAtlasPointMarker,
- LiveAtlasMarkerSet, LiveAtlasMarkerSetContents,
+ LiveAtlasLineMarker, LiveAtlasMarker,
+ LiveAtlasMarkerSet,
LiveAtlasPartialComponentConfig,
LiveAtlasPlayer,
+ LiveAtlasPointMarker,
LiveAtlasServerConfig,
LiveAtlasServerDefinition,
LiveAtlasServerMessageConfig,
@@ -35,6 +35,7 @@ import {MutationTypes} from "@/store/mutation-types";
import MapProvider from "@/providers/MapProvider";
import {ActionTypes} from "@/store/action-types";
import {getMiddleFromPoints, stripHTML, titleColoursRegex} from "@/util";
+import {LiveAtlasMarkerType} from "@/util/markers";
export default class Pl3xmapMapProvider extends MapProvider {
private configurationAbort?: AbortController = undefined;
@@ -57,7 +58,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
}> = new Map();
private markerSets: Map = new Map();
- private markers = new Map();
+ private markers = new Map>();
constructor(config: LiveAtlasServerDefinition) {
super(config);
@@ -244,31 +245,33 @@ export default class Pl3xmapMapProvider extends MapProvider {
return;
}
- const id = set.id;
-
- const points: Map = Object.freeze(new Map()),
- circles: Map = Object.freeze(new Map()),
- areas: Map = Object.freeze(new Map()),
- lines: Map = Object.freeze(new Map());
+ const id = set.id,
+ markers: Map = Object.freeze(new Map());
(set.markers || []).forEach((marker: any) => {
+ let markerId;
+
switch(marker.type) {
case 'icon':
- points.set(`marker-${points.size}`, Pl3xmapMapProvider.buildMarker(marker));
+ markerId = `point_${markers.size}`;
+ markers.set(markerId, Pl3xmapMapProvider.buildMarker(markerId, marker));
break;
case 'polyline':
- lines.set(`line-${lines.size}`, Pl3xmapMapProvider.buildLine(marker));
+ markerId = `line_${markers.size}`;
+ markers.set(markerId, Pl3xmapMapProvider.buildLine(markerId, marker));
break;
case 'rectangle':
case 'polygon':
- areas.set(`area-${areas.size}`, Pl3xmapMapProvider.buildArea(marker));
+ markerId = `area_${markers.size}`;
+ markers.set(markerId, Pl3xmapMapProvider.buildArea(markerId, marker));
break;
case 'circle':
case 'ellipse':
- circles.set(`circle-${circles.size}`, Pl3xmapMapProvider.buildCircle(marker));
+ markerId = `circle_${markers.size}`;
+ markers.set(markerId, Pl3xmapMapProvider.buildCircle(markerId, marker));
break;
default:
@@ -283,12 +286,14 @@ export default class Pl3xmapMapProvider extends MapProvider {
priority: set.order || 0,
showLabels: false
});
- this.markers.set(id, Object.seal({points, circles, areas, lines}));
+ this.markers.set(id, markers);
});
}
- private static buildMarker(marker: any): LiveAtlasPointMarker {
+ private static buildMarker(id: string, marker: any): LiveAtlasPointMarker {
return {
+ id,
+ type: LiveAtlasMarkerType.POINT,
location: {
x: marker.point?.x || 0,
y: 0,
@@ -304,7 +309,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
};
}
- private static buildArea(area: any): LiveAtlasAreaMarker {
+ private static buildArea(id: string, area: any): LiveAtlasAreaMarker {
let points = area.points;
if(area.type === 'rectangle') {
@@ -317,6 +322,8 @@ export default class Pl3xmapMapProvider extends MapProvider {
}
return {
+ id,
+ type: LiveAtlasMarkerType.AREA,
style: {
stroke: typeof area.stroke !== 'undefined' ? !!area.stroke : true,
color: area.color || '#3388ff',
@@ -338,10 +345,12 @@ export default class Pl3xmapMapProvider extends MapProvider {
};
}
- private static buildLine(line: any): LiveAtlasLineMarker {
+ private static buildLine(id: string, line: any): LiveAtlasLineMarker {
const points = this.addY(line.points);
return {
+ id,
+ type: LiveAtlasMarkerType.LINE,
style: {
stroke: typeof line.stroke !== 'undefined' ? !!line.stroke : true,
color: line.color || '#3388ff',
@@ -358,8 +367,10 @@ export default class Pl3xmapMapProvider extends MapProvider {
};
}
- private static buildCircle(circle: any): LiveAtlasCircleMarker {
+ private static buildCircle(id: string, circle: any): LiveAtlasCircleMarker {
return {
+ id,
+ type: LiveAtlasMarkerType.CIRCLE,
location: {
x: circle.center?.x || 0,
y: 0,
diff --git a/src/store/mutations.ts b/src/store/mutations.ts
index 142c36b..c3b2e2e 100644
--- a/src/store/mutations.ts
+++ b/src/store/mutations.ts
@@ -32,10 +32,6 @@ import {
LiveAtlasGlobalConfig,
LiveAtlasServerMessageConfig,
LiveAtlasPlayer,
- LiveAtlasCircleMarker,
- LiveAtlasLineMarker,
- LiveAtlasAreaMarker,
- LiveAtlasPointMarker,
LiveAtlasMarkerSet,
LiveAtlasServerDefinition,
LiveAtlasServerConfig,
@@ -43,12 +39,11 @@ import {
LiveAtlasPartialComponentConfig,
LiveAtlasComponentConfig,
LiveAtlasUIModal,
- LiveAtlasSidebarSectionState, LiveAtlasMarkerSetContents
+ LiveAtlasSidebarSectionState, LiveAtlasMarker
} from "@/index";
import DynmapMapProvider from "@/providers/DynmapMapProvider";
import Pl3xmapMapProvider from "@/providers/Pl3xmapMapProvider";
import {getGlobalMessages} from "@/util";
-import {LiveAtlasMarkerType} from "@/util/markers";
export type CurrentMapPayload = {
worldName: string;
@@ -63,7 +58,7 @@ export type Mutations = {
[MutationTypes.SET_WORLDS](state: S, worlds: Array): void
[MutationTypes.SET_COMPONENTS](state: S, components: LiveAtlasPartialComponentConfig | LiveAtlasComponentConfig): void
[MutationTypes.SET_MARKER_SETS](state: S, markerSets: Map): void
- [MutationTypes.SET_MARKERS](state: S, markers: Map): void
+ [MutationTypes.SET_MARKERS](state: S, markers: Map>): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: DynmapMarkerSetUpdate[]): void
[MutationTypes.ADD_MARKER_UPDATES](state: S, updates: DynmapMarkerUpdate[]): void
@@ -209,17 +204,12 @@ export const mutations: MutationTree & Mutations = {
for(const entry of markerSets) {
state.markerSets.set(entry[0], entry[1]);
- nonReactiveState.markers.set(entry[0], {
- points: new Map(),
- areas: new Map(),
- lines: new Map(),
- circles: new Map(),
- });
+ nonReactiveState.markers.set(entry[0], new Map());
}
},
//Sets the existing marker sets from the last marker fetch
- [MutationTypes.SET_MARKERS](state: State, markers: Map) {
+ [MutationTypes.SET_MARKERS](state: State, markers: Map>) {
nonReactiveState.markers.clear();
for(const entry of markers) {
@@ -261,12 +251,7 @@ export const mutations: MutationTree & Mutations = {
label: update.payload.label,
hidden: update.payload.hidden,
});
- nonReactiveState.markers.set(update.id, {
- points: new Map(),
- areas: new Map(),
- lines: new Map(),
- circles: new Map(),
- });
+ nonReactiveState.markers.set(update.id, new Map());
}
}
}
@@ -281,41 +266,12 @@ export const mutations: MutationTree & Mutations = {
continue;
}
- setContents = nonReactiveState.markers.get(update.set) as LiveAtlasMarkerSetContents;
+ setContents = nonReactiveState.markers.get(update.set) as Map;
- switch (update.type) {
- case LiveAtlasMarkerType.POINT:
- if(update.removed) {
- setContents.points.delete(update.id);
- } else {
- setContents.points.set(update.id, update.payload as LiveAtlasPointMarker);
- }
-
- continue;
- case LiveAtlasMarkerType.AREA:
- if(update.removed) {
- setContents.areas.delete(update.id);
- } else {
- setContents.areas.set(update.id, update.payload as LiveAtlasAreaMarker);
- }
-
- continue;
-
- case LiveAtlasMarkerType.LINE:
- if(update.removed) {
- setContents.lines.delete(update.id);
- } else {
- setContents.lines.set(update.id, update.payload as LiveAtlasLineMarker);
- }
-
- continue;
-
- case LiveAtlasMarkerType.CIRCLE:
- if(update.removed) {
- setContents.circles.delete(update.id);
- } else {
- setContents.circles.set(update.id, update.payload as LiveAtlasCircleMarker);
- }
+ if(update.removed) {
+ setContents.delete(update.id);
+ } else {
+ setContents.set(update.id, update.payload);
}
}
diff --git a/src/store/state.ts b/src/store/state.ts
index d21c040..1a1c197 100644
--- a/src/store/state.ts
+++ b/src/store/state.ts
@@ -36,7 +36,7 @@ import {
LiveAtlasChat,
LiveAtlasUIModal,
LiveAtlasSidebarSectionState,
- LiveAtlasMarkerSetContents
+ LiveAtlasMarker
} from "@/index";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {getMessages} from "@/util";
@@ -220,5 +220,5 @@ export const state: State = {
};
export const nonReactiveState = Object.freeze({
- markers: new Map(),
+ markers: new Map>(),
});
diff --git a/src/util/dynmap.ts b/src/util/dynmap.ts
index 3f9dc66..699b027 100644
--- a/src/util/dynmap.ts
+++ b/src/util/dynmap.ts
@@ -21,8 +21,9 @@ import {
LiveAtlasCircleMarker,
LiveAtlasComponentConfig,
LiveAtlasDimension,
- LiveAtlasLineMarker,
- LiveAtlasPointMarker, LiveAtlasPlayerImageSize,
+ LiveAtlasLineMarker, LiveAtlasMarker,
+ LiveAtlasPlayerImageSize,
+ LiveAtlasPointMarker,
LiveAtlasServerConfig,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition
@@ -40,7 +41,11 @@ import {getLinePoints} from "@/util/lines";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {
Configuration,
- Marker, MarkerArea, MarkerCircle, MarkerLine, MarkerSet,
+ Marker,
+ MarkerArea,
+ MarkerCircle,
+ MarkerLine,
+ MarkerSet,
Options,
WorldConfiguration,
WorldMapConfiguration
@@ -275,21 +280,20 @@ export function buildMarkerSet(id: string, data: MarkerSet): any {
}
}
-export function buildMarkers(data: any): Map {
- const markers = Object.freeze(new Map()) as Map;
+export function buildMarkers(data: any, list: Map): void {
+ let id;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
continue;
}
- markers.set(key, buildMarker(data[key]));
+ id = `point_${key}`;
+ list.set(id, buildMarker(id, data[key]));
}
-
- return markers;
}
-export function buildMarker(data: Marker): LiveAtlasPointMarker {
+export function buildMarker(id: string, data: Marker): LiveAtlasPointMarker {
let dimensions;
if(data.dim) {
@@ -301,6 +305,8 @@ export function buildMarker(data: Marker): LiveAtlasPointMarker {
}
const marker = {
+ id,
+ type: LiveAtlasMarkerType.POINT,
location: {
x: data.x || 0,
y: data.y || 0,
@@ -314,7 +320,7 @@ export function buildMarker(data: Marker): LiveAtlasPointMarker {
tooltipHTML: data.markup ? data.label : undefined,
popup: data.desc || undefined,
isPopupHTML: true,
- };
+ } as LiveAtlasPointMarker;
//Fix double escaping on non-HTML labels
if(!marker.tooltipHTML) {
@@ -324,26 +330,27 @@ export function buildMarker(data: Marker): LiveAtlasPointMarker {
return marker;
}
-export function buildAreas(data: any): Map {
- const areas = Object.freeze(new Map()) as Map;
+export function buildAreas(data: any, list: Map): void {
+ let id;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
continue;
}
- areas.set(key, buildArea(data[key]));
+ id = `area_${key}`;
+ list.set(id, buildArea(id, data[key]));
}
-
- return areas;
}
-export function buildArea(area: MarkerArea): LiveAtlasAreaMarker {
+export function buildArea(id: string, area: MarkerArea): LiveAtlasAreaMarker {
const x = area.x || [0, 0],
y = [area.ybottom || 0, area.ytop || 0] as [number, number],
z = area.z || [0, 0];
return {
+ id,
+ type: LiveAtlasMarkerType.AREA,
style: {
color: area.color || '#ff0000',
opacity: area.opacity || 1,
@@ -364,26 +371,27 @@ export function buildArea(area: MarkerArea): LiveAtlasAreaMarker {
};
}
-export function buildLines(data: any): Map {
- const lines = Object.freeze(new Map()) as Map;
+export function buildLines(data: any, list: Map): void {
+ let id;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
continue;
}
- lines.set(key, buildLine(data[key]));
+ id = `line_${key}`;
+ list.set(id, buildLine(id, data[key]));
}
-
- return lines;
}
-export function buildLine(line: MarkerLine): LiveAtlasLineMarker {
+export function buildLine(id: string, line: MarkerLine): LiveAtlasLineMarker {
const x = line.x || [0, 0],
y = line.y || [0, 0],
z = line.z || [0, 0];
return {
+ id,
+ type: LiveAtlasMarkerType.LINE,
style: {
color: line.color || '#ff0000',
opacity: line.opacity || 1,
@@ -401,22 +409,23 @@ export function buildLine(line: MarkerLine): LiveAtlasLineMarker {
};
}
-export function buildCircles(data: any): Map {
- const circles = Object.freeze(new Map()) as Map;
+export function buildCircles(data: any, list: Map): void {
+ let id;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
continue;
}
- circles.set(key, buildCircle(data[key]));
+ id = `circle_${key}`;
+ list.set(id, buildCircle(id, data[key]));
}
-
- return circles;
}
-export function buildCircle(circle: MarkerCircle): LiveAtlasCircleMarker {
+export function buildCircle(id: string, circle: MarkerCircle): LiveAtlasCircleMarker {
return {
+ id,
+ type: LiveAtlasMarkerType.CIRCLE,
location: {
x: circle.x || 0,
y: circle.y || 0,
@@ -499,17 +508,21 @@ export function buildUpdates(data: Array, lastUpdate: Date) {
updates.markerSets.push(Object.freeze(update as DynmapMarkerSetUpdate));
} else {
if (entry.msg.startsWith("marker")) {
+ update.id = `point_${entry.id}`;
update.type = LiveAtlasMarkerType.POINT;
- update.payload = update.removed ? undefined : buildMarker(entry);
+ update.payload = update.removed ? undefined : buildMarker(update.id, entry);
} else if (entry.msg.startsWith("area")) {
+ update.id = `area_${entry.id}`;
update.type = LiveAtlasMarkerType.AREA;
- update.payload = update.removed ? undefined : buildArea(entry);
+ update.payload = update.removed ? undefined : buildArea(update.id, entry);
} else if (entry.msg.startsWith("circle")) {
+ update.id = `circle_${entry.id}`;
update.type = LiveAtlasMarkerType.CIRCLE;
- update.payload = update.removed ? undefined : buildCircle(entry);
+ update.payload = update.removed ? undefined : buildCircle(update.id, entry);
} else if (entry.msg.startsWith("line")) {
+ update.id = `line_${entry.id}`;
update.type = LiveAtlasMarkerType.LINE;
- update.payload = update.removed ? undefined : buildLine(entry);
+ update.payload = update.removed ? undefined : buildLine(update.id, entry);
}
updates.markers.push(Object.freeze(update as DynmapMarkerUpdate));
diff --git a/src/util/markers.ts b/src/util/markers.ts
index baf2775..a015175 100644
--- a/src/util/markers.ts
+++ b/src/util/markers.ts
@@ -22,6 +22,21 @@ import {ActionTypes} from "@/store/action-types";
import {DynmapMarkerUpdate} from "@/dynmap";
import {computed, watch} from "@vue/runtime-core";
import {ComputedRef} from "@vue/reactivity";
+import {
+ LiveAtlasAreaMarker,
+ LiveAtlasCircleMarker,
+ LiveAtlasLineMarker,
+ LiveAtlasMarker,
+ LiveAtlasPointMarker
+} from "@/index";
+import {Layer} from "leaflet";
+import {createCircle, updateCircle} from "@/util/circles";
+import {createPointMarker, updatePointMarker} from "@/util/points";
+import {createArea, updateArea} from "@/util/areas";
+import {createLine, updateLine} from "@/util/lines";
+import {GenericMarker} from "@/leaflet/marker/GenericMarker";
+import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
+import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
export type LiveAtlasMarkerUpdateCallback = ((update: DynmapMarkerUpdate) => void);
@@ -35,8 +50,7 @@ export enum LiveAtlasMarkerType {
let updateFrame = 0;
let pendingUpdates: ComputedRef;
-const setHandlers: { [key:string]: Set} = {};
-const typeHandlers: { [key:string]: Map>} = {};
+const updateHandlers: { [key:string]: Set} = {};
export const startUpdateHandling = () => {
const store = useStore();
@@ -58,41 +72,19 @@ export const stopUpdateHandling = () => {
}
export const registerUpdateHandler = (callback: LiveAtlasMarkerUpdateCallback, set: string) => {
- if(!setHandlers[set]) {
- setHandlers[set] = new Set();
+ if(!updateHandlers[set]) {
+ updateHandlers[set] = new Set();
}
- setHandlers[set].add(callback);
-}
-
-export const registerTypeUpdateHandler = (callback: LiveAtlasMarkerUpdateCallback, set: string, type: LiveAtlasMarkerType) => {
- if(!typeHandlers[set]) {
- typeHandlers[set] = new Map();
- }
-
- if(typeHandlers[set].has(type)) {
- typeHandlers[set].get(type)!.add(callback);
- } else {
- typeHandlers[set].set(type, new Set([callback]));
- }
+ updateHandlers[set].add(callback);
}
export const unregisterUpdateHandler = (callback: LiveAtlasMarkerUpdateCallback, set: string) => {
- if(!setHandlers[set]) {
+ if(!updateHandlers[set]) {
return;
}
- setHandlers[set].delete(callback);
-}
-
-export const unregisterTypeUpdateHandler = (callback: LiveAtlasMarkerUpdateCallback, set: string, type: LiveAtlasMarkerType) => {
- if(typeHandlers[set]) {
- return;
- }
-
- if(typeHandlers[set].has(type)) {
- typeHandlers[set].get(type)!.delete(callback);
- }
+ updateHandlers[set].delete(callback);
}
const handlePendingUpdates = async () => {
@@ -100,12 +92,8 @@ const handlePendingUpdates = async () => {
updates = await store.dispatch(ActionTypes.POP_MARKER_UPDATES, 10);
for(const update of updates) {
- if(setHandlers[update.set]) {
- setHandlers[update.set].forEach(callback => callback(update));
- }
-
- if(typeHandlers[update.set] && typeHandlers[update.set].has(update.type)) {
- typeHandlers[update.set].get(update.type)!.forEach(callback => callback(update));
+ if(updateHandlers[update.set]) {
+ updateHandlers[update.set].forEach(callback => callback(update));
}
}
@@ -116,3 +104,29 @@ const handlePendingUpdates = async () => {
updateFrame = 0;
}
};
+
+export const createMarker = (options: LiveAtlasMarker, converter: Function): Layer => {
+ switch(options.type) {
+ case LiveAtlasMarkerType.POINT:
+ return createPointMarker(options as LiveAtlasPointMarker, converter);
+ case LiveAtlasMarkerType.AREA:
+ return createArea(options as LiveAtlasAreaMarker, converter);
+ case LiveAtlasMarkerType.LINE:
+ return createLine(options as LiveAtlasLineMarker, converter);
+ case LiveAtlasMarkerType.CIRCLE:
+ return createCircle(options as LiveAtlasCircleMarker, converter);
+ }
+}
+
+export const updateMarker = (marker: Layer | undefined, options: LiveAtlasMarker, converter: Function): Layer => {
+ switch(options.type) {
+ case LiveAtlasMarkerType.POINT:
+ return updatePointMarker(marker as GenericMarker, options as LiveAtlasPointMarker, converter);
+ case LiveAtlasMarkerType.AREA:
+ return updateArea(marker as LiveAtlasPolygon | LiveAtlasPolyline, options as LiveAtlasAreaMarker, converter);
+ case LiveAtlasMarkerType.LINE:
+ return updateLine(marker as LiveAtlasPolyline, options as LiveAtlasLineMarker, converter);
+ case LiveAtlasMarkerType.CIRCLE:
+ return updateCircle(marker as LiveAtlasPolyline | LiveAtlasPolygon, options as LiveAtlasCircleMarker, converter);
+ }
+}