Rename marker layer utility methods

This commit is contained in:
James Lyne 2022-01-15 18:45:01 +00:00
parent 5391b2a34c
commit cfda231048
6 changed files with 31 additions and 31 deletions

View File

@ -22,8 +22,8 @@ import {LiveAtlasAreaMarker, LiveAtlasMarker, LiveAtlasMarkerSet} from "@/index"
import {nonReactiveState} from "@/store/state";
import {DynmapMarkerUpdate} from "@/dynmap";
import {
createMarker,
registerUpdateHandler, unregisterUpdateHandler, updateMarker
createMarkerLayer,
registerUpdateHandler, unregisterUpdateHandler, updateMarkerLayer
} from "@/util/markers";
import {Layer} from "leaflet";
@ -48,7 +48,7 @@ export default defineComponent({
const createMarkers = () => {
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);
props.layerGroup.addLayer(layer);
@ -70,7 +70,7 @@ export default defineComponent({
if(update.removed) {
deleteMarker(update.id);
} 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)) {
props.layerGroup.addLayer(layer);
@ -85,7 +85,7 @@ export default defineComponent({
converter = newValue.locationToLatLng.bind(newValue);
for (const [id, area] of nonReactiveState.markers.get(props.set.id)!) {
updateMarker(layers.get(id), area, converter);
updateMarkerLayer(layers.get(id), area, converter);
}
}
});

View File

@ -23,7 +23,7 @@ import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import {Coordinate, LiveAtlasAreaMarker} from "@/index";
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),
points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],
area = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
@ -39,9 +39,9 @@ export const createArea = (options: LiveAtlasAreaMarker, converter: Function): L
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) {
return createArea(options, converter);
return createAreaLayer(options, converter);
}
const points = options.points.map(projectPointsMapCallback, converter) as LatLngExpression[] | LatLngExpression[][],

View File

@ -23,7 +23,7 @@ import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import {LiveAtlasCircleMarker} from "@/index";
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),
points = getCirclePoints(options, converter, outline),
circle = outline ? new LiveAtlasPolyline(points, options) : new LiveAtlasPolygon(points, options);
@ -39,9 +39,9 @@ export const createCircle = (options: LiveAtlasCircleMarker, converter: Function
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) {
return createCircle(options, converter);
return createCircleLayer(options, converter);
}
const outline = (options.style && options.style.fillOpacity && (options.style.fillOpacity <= 0)) as boolean;

View File

@ -22,7 +22,7 @@ import {Coordinate, LiveAtlasLineMarker} from "@/index";
import {LatLngExpression} from "leaflet";
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),
line = new LiveAtlasPolyline(points, options);
@ -37,9 +37,9 @@ export const createLine = (options: LiveAtlasLineMarker, converter: Function): L
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) {
return createLine(options, converter);
return createLineLayer(options, converter);
}
line.closePopup();

View File

@ -30,10 +30,10 @@ import {
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 {createCircleLayer, updateCircleLayer} from "@/util/circles";
import {createPointLayer, updatePointLayer} from "@/util/points";
import {createAreaLayer, updateAreaLayer} from "@/util/areas";
import {createLineLayer, updateLineLayer} from "@/util/lines";
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
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) {
case LiveAtlasMarkerType.POINT:
return createPointMarker(options as LiveAtlasPointMarker, converter);
return createPointLayer(options as LiveAtlasPointMarker, converter);
case LiveAtlasMarkerType.AREA:
return createArea(options as LiveAtlasAreaMarker, converter);
return createAreaLayer(options as LiveAtlasAreaMarker, converter);
case LiveAtlasMarkerType.LINE:
return createLine(options as LiveAtlasLineMarker, converter);
return createLineLayer(options as LiveAtlasLineMarker, converter);
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) {
case LiveAtlasMarkerType.POINT:
return updatePointMarker(marker as GenericMarker, options as LiveAtlasPointMarker, converter);
return updatePointLayer(marker as GenericMarker, options as LiveAtlasPointMarker, converter);
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:
return updateLine(marker as LiveAtlasPolyline, options as LiveAtlasLineMarker, converter);
return updateLineLayer(marker as LiveAtlasPolyline, options as LiveAtlasLineMarker, converter);
case LiveAtlasMarkerType.CIRCLE:
return updateCircle(marker as LiveAtlasPolyline | LiveAtlasPolygon, options as LiveAtlasCircleMarker, converter);
return updateCircleLayer(marker as LiveAtlasPolyline | LiveAtlasPolygon, options as LiveAtlasCircleMarker, converter);
}
}

View File

@ -22,7 +22,7 @@ import {GenericIcon} from "@/leaflet/icon/GenericIcon";
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
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);
marker.on('click', (e: LeafletMouseEvent) => {
@ -38,9 +38,9 @@ export const createPointMarker = (options: LiveAtlasPointMarker, converter: Func
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) {
return createPointMarker(options, converter);
return createPointLayer(options, converter);
}
const oldLocation = marker.getLatLng(),