Rename marker layer utility methods
This commit is contained in:
parent
5391b2a34c
commit
cfda231048
@ -22,8 +22,8 @@ import {LiveAtlasAreaMarker, LiveAtlasMarker, LiveAtlasMarkerSet} from "@/index"
|
|||||||
import {nonReactiveState} from "@/store/state";
|
import {nonReactiveState} from "@/store/state";
|
||||||
import {DynmapMarkerUpdate} from "@/dynmap";
|
import {DynmapMarkerUpdate} from "@/dynmap";
|
||||||
import {
|
import {
|
||||||
createMarker,
|
createMarkerLayer,
|
||||||
registerUpdateHandler, unregisterUpdateHandler, updateMarker
|
registerUpdateHandler, unregisterUpdateHandler, updateMarkerLayer
|
||||||
} from "@/util/markers";
|
} from "@/util/markers";
|
||||||
import {Layer} from "leaflet";
|
import {Layer} from "leaflet";
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const createMarkers = () => {
|
const createMarkers = () => {
|
||||||
nonReactiveState.markers.get(props.set.id)!.forEach((area: LiveAtlasMarker, id: string) => {
|
nonReactiveState.markers.get(props.set.id)!.forEach((area: LiveAtlasMarker, id: string) => {
|
||||||
const layer = createMarker(area, converter);
|
const layer = createMarkerLayer(area, converter);
|
||||||
|
|
||||||
layers.set(id, layer);
|
layers.set(id, layer);
|
||||||
props.layerGroup.addLayer(layer);
|
props.layerGroup.addLayer(layer);
|
||||||
@ -70,7 +70,7 @@ export default defineComponent({
|
|||||||
if(update.removed) {
|
if(update.removed) {
|
||||||
deleteMarker(update.id);
|
deleteMarker(update.id);
|
||||||
} else {
|
} else {
|
||||||
const layer = updateMarker(layers.get(update.id), update.payload as LiveAtlasAreaMarker, converter);
|
const layer = updateMarkerLayer(layers.get(update.id), update.payload as LiveAtlasAreaMarker, converter);
|
||||||
|
|
||||||
if(!layers.has(update.id)) {
|
if(!layers.has(update.id)) {
|
||||||
props.layerGroup.addLayer(layer);
|
props.layerGroup.addLayer(layer);
|
||||||
@ -85,7 +85,7 @@ export default defineComponent({
|
|||||||
converter = newValue.locationToLatLng.bind(newValue);
|
converter = newValue.locationToLatLng.bind(newValue);
|
||||||
|
|
||||||
for (const [id, area] of nonReactiveState.markers.get(props.set.id)!) {
|
for (const [id, area] of nonReactiveState.markers.get(props.set.id)!) {
|
||||||
updateMarker(layers.get(id), area, converter);
|
updateMarkerLayer(layers.get(id), area, converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
|
|||||||
import {Coordinate, LiveAtlasAreaMarker} from "@/index";
|
import {Coordinate, LiveAtlasAreaMarker} from "@/index";
|
||||||
import {arePointsEqual, createPopup, isStyleEqual, tooltipOptions} from "@/util/paths";
|
import {arePointsEqual, createPopup, isStyleEqual, tooltipOptions} from "@/util/paths";
|
||||||
|
|
||||||
export const createArea = (options: LiveAtlasAreaMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
export const createAreaLayer = (options: LiveAtlasAreaMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
||||||
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
|
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
|
||||||
points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],
|
points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],
|
||||||
area = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
|
area = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
|
||||||
@ -39,9 +39,9 @@ export const createArea = (options: LiveAtlasAreaMarker, converter: Function): L
|
|||||||
return area;
|
return area;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateArea = (area: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasAreaMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
export const updateAreaLayer = (area: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasAreaMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
||||||
if (!area) {
|
if (!area) {
|
||||||
return createArea(options, converter);
|
return createAreaLayer(options, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],
|
const points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],
|
||||||
|
@ -23,7 +23,7 @@ import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
|
|||||||
import {LiveAtlasCircleMarker} from "@/index";
|
import {LiveAtlasCircleMarker} from "@/index";
|
||||||
import {createPopup, tooltipOptions} from "@/util/paths";
|
import {createPopup, tooltipOptions} from "@/util/paths";
|
||||||
|
|
||||||
export const createCircle = (options: LiveAtlasCircleMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
export const createCircleLayer = (options: LiveAtlasCircleMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
||||||
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
|
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
|
||||||
points = getCirclePoints(options, converter, outline),
|
points = getCirclePoints(options, converter, outline),
|
||||||
circle = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
|
circle = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
|
||||||
@ -39,9 +39,9 @@ export const createCircle = (options: LiveAtlasCircleMarker, converter: Function
|
|||||||
return circle;
|
return circle;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateCircle = (circle: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasCircleMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
export const updateCircleLayer = (circle: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasCircleMarker, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
|
||||||
if (!circle) {
|
if (!circle) {
|
||||||
return createCircle(options, converter);
|
return createCircleLayer(options, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const outline = (options.style && options.style.fillOpacity && (options.style.fillOpacity <= 0)) as boolean;
|
const outline = (options.style && options.style.fillOpacity && (options.style.fillOpacity <= 0)) as boolean;
|
||||||
|
@ -22,7 +22,7 @@ import {Coordinate, LiveAtlasLineMarker} from "@/index";
|
|||||||
import {LatLngExpression} from "leaflet";
|
import {LatLngExpression} from "leaflet";
|
||||||
import {createPopup, tooltipOptions} from "@/util/paths";
|
import {createPopup, tooltipOptions} from "@/util/paths";
|
||||||
|
|
||||||
export const createLine = (options: LiveAtlasLineMarker, converter: Function): LiveAtlasPolyline => {
|
export const createLineLayer = (options: LiveAtlasLineMarker, converter: Function): LiveAtlasPolyline => {
|
||||||
const points = options.points.map(projectPointsMapCallback, converter),
|
const points = options.points.map(projectPointsMapCallback, converter),
|
||||||
line = new LiveAtlasPolyline(points, options);
|
line = new LiveAtlasPolyline(points, options);
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ export const createLine = (options: LiveAtlasLineMarker, converter: Function): L
|
|||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateLine = (line: LiveAtlasPolyline | undefined, options: LiveAtlasLineMarker, converter: Function): LiveAtlasPolyline => {
|
export const updateLineLayer = (line: LiveAtlasPolyline | undefined, options: LiveAtlasLineMarker, converter: Function): LiveAtlasPolyline => {
|
||||||
if (!line) {
|
if (!line) {
|
||||||
return createLine(options, converter);
|
return createLineLayer(options, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
line.closePopup();
|
line.closePopup();
|
||||||
|
@ -30,10 +30,10 @@ import {
|
|||||||
LiveAtlasPointMarker
|
LiveAtlasPointMarker
|
||||||
} from "@/index";
|
} from "@/index";
|
||||||
import {Layer} from "leaflet";
|
import {Layer} from "leaflet";
|
||||||
import {createCircle, updateCircle} from "@/util/circles";
|
import {createCircleLayer, updateCircleLayer} from "@/util/circles";
|
||||||
import {createPointMarker, updatePointMarker} from "@/util/points";
|
import {createPointLayer, updatePointLayer} from "@/util/points";
|
||||||
import {createArea, updateArea} from "@/util/areas";
|
import {createAreaLayer, updateAreaLayer} from "@/util/areas";
|
||||||
import {createLine, updateLine} from "@/util/lines";
|
import {createLineLayer, updateLineLayer} from "@/util/lines";
|
||||||
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
|
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
|
||||||
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
|
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
|
||||||
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
|
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
|
||||||
@ -105,28 +105,28 @@ const handlePendingUpdates = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createMarker = (options: LiveAtlasMarker, converter: Function): Layer => {
|
export const createMarkerLayer = (options: LiveAtlasMarker, converter: Function): Layer => {
|
||||||
switch(options.type) {
|
switch(options.type) {
|
||||||
case LiveAtlasMarkerType.POINT:
|
case LiveAtlasMarkerType.POINT:
|
||||||
return createPointMarker(options as LiveAtlasPointMarker, converter);
|
return createPointLayer(options as LiveAtlasPointMarker, converter);
|
||||||
case LiveAtlasMarkerType.AREA:
|
case LiveAtlasMarkerType.AREA:
|
||||||
return createArea(options as LiveAtlasAreaMarker, converter);
|
return createAreaLayer(options as LiveAtlasAreaMarker, converter);
|
||||||
case LiveAtlasMarkerType.LINE:
|
case LiveAtlasMarkerType.LINE:
|
||||||
return createLine(options as LiveAtlasLineMarker, converter);
|
return createLineLayer(options as LiveAtlasLineMarker, converter);
|
||||||
case LiveAtlasMarkerType.CIRCLE:
|
case LiveAtlasMarkerType.CIRCLE:
|
||||||
return createCircle(options as LiveAtlasCircleMarker, converter);
|
return createCircleLayer(options as LiveAtlasCircleMarker, converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateMarker = (marker: Layer | undefined, options: LiveAtlasMarker, converter: Function): Layer => {
|
export const updateMarkerLayer = (marker: Layer | undefined, options: LiveAtlasMarker, converter: Function): Layer => {
|
||||||
switch(options.type) {
|
switch(options.type) {
|
||||||
case LiveAtlasMarkerType.POINT:
|
case LiveAtlasMarkerType.POINT:
|
||||||
return updatePointMarker(marker as GenericMarker, options as LiveAtlasPointMarker, converter);
|
return updatePointLayer(marker as GenericMarker, options as LiveAtlasPointMarker, converter);
|
||||||
case LiveAtlasMarkerType.AREA:
|
case LiveAtlasMarkerType.AREA:
|
||||||
return updateArea(marker as LiveAtlasPolygon | LiveAtlasPolyline, options as LiveAtlasAreaMarker, converter);
|
return updateAreaLayer(marker as LiveAtlasPolygon | LiveAtlasPolyline, options as LiveAtlasAreaMarker, converter);
|
||||||
case LiveAtlasMarkerType.LINE:
|
case LiveAtlasMarkerType.LINE:
|
||||||
return updateLine(marker as LiveAtlasPolyline, options as LiveAtlasLineMarker, converter);
|
return updateLineLayer(marker as LiveAtlasPolyline, options as LiveAtlasLineMarker, converter);
|
||||||
case LiveAtlasMarkerType.CIRCLE:
|
case LiveAtlasMarkerType.CIRCLE:
|
||||||
return updateCircle(marker as LiveAtlasPolyline | LiveAtlasPolygon, options as LiveAtlasCircleMarker, converter);
|
return updateCircleLayer(marker as LiveAtlasPolyline | LiveAtlasPolygon, options as LiveAtlasCircleMarker, converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import {GenericIcon} from "@/leaflet/icon/GenericIcon";
|
|||||||
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
|
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
|
||||||
import {LiveAtlasPointMarker} from "@/index";
|
import {LiveAtlasPointMarker} from "@/index";
|
||||||
|
|
||||||
export const createPointMarker = (options: LiveAtlasPointMarker, converter: Function): Marker => {
|
export const createPointLayer = (options: LiveAtlasPointMarker, converter: Function): Marker => {
|
||||||
const marker = new GenericMarker(converter(options.location), options);
|
const marker = new GenericMarker(converter(options.location), options);
|
||||||
|
|
||||||
marker.on('click', (e: LeafletMouseEvent) => {
|
marker.on('click', (e: LeafletMouseEvent) => {
|
||||||
@ -38,9 +38,9 @@ export const createPointMarker = (options: LiveAtlasPointMarker, converter: Func
|
|||||||
return marker;
|
return marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updatePointMarker = (marker: Marker | undefined, options: LiveAtlasPointMarker, converter: Function): Marker => {
|
export const updatePointLayer = (marker: Marker | undefined, options: LiveAtlasPointMarker, converter: Function): Marker => {
|
||||||
if (!marker) {
|
if (!marker) {
|
||||||
return createPointMarker(options, converter);
|
return createPointLayer(options, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldLocation = marker.getLatLng(),
|
const oldLocation = marker.getLatLng(),
|
||||||
|
Loading…
Reference in New Issue
Block a user