From 87a1665d531ad07eeff727339bbc556987189617 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Thu, 24 Feb 2022 21:08:27 +0000 Subject: [PATCH] Rename GenericMarker dimensions to iconSize and make optional --- src/index.d.ts | 2 +- src/leaflet/icon/GenericIcon.ts | 4 ++-- src/leaflet/marker/GenericMarker.ts | 2 +- src/providers/OverviewerMapProvider.ts | 3 ++- src/providers/Pl3xmapMapProvider.ts | 2 +- src/util/dynmap.ts | 2 +- src/util/points.ts | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 5b07542..82c5607 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -217,8 +217,8 @@ interface LiveAtlasMarker { interface LiveAtlasPointMarker extends LiveAtlasMarker { type: LiveAtlasMarkerType.POINT; - dimensions: PointTuple; iconUrl: string; + iconSize?: PointTuple; } interface LiveAtlasPathMarker extends LiveAtlasMarker { diff --git a/src/leaflet/icon/GenericIcon.ts b/src/leaflet/icon/GenericIcon.ts index e69d16c..0b6018f 100644 --- a/src/leaflet/icon/GenericIcon.ts +++ b/src/leaflet/icon/GenericIcon.ts @@ -24,7 +24,7 @@ export interface GenericIconOptions extends BaseIconOptions { label: string; isHtml?: boolean; showLabel?: boolean; - iconSize: PointTuple; + iconSize?: PointTuple; className?: string; } @@ -40,7 +40,7 @@ markerLabel.className = 'marker__label'; const defaultOptions: GenericIconOptions = { iconUrl: 'default', label: '', - iconSize: [16, 16], + iconSize: undefined, popupAnchor: [0, 0], iconAnchor: [0, 0], tooltipAnchor: [0, 0], diff --git a/src/leaflet/marker/GenericMarker.ts b/src/leaflet/marker/GenericMarker.ts index 46ac2fc..6bbee80 100644 --- a/src/leaflet/marker/GenericMarker.ts +++ b/src/leaflet/marker/GenericMarker.ts @@ -33,7 +33,7 @@ export class GenericMarker extends Marker { this.options.icon = new GenericIcon({ iconUrl: options.iconUrl, label: options.tooltipHTML || options.tooltip, - iconSize: options.dimensions, + iconSize: options.iconSize, isHtml: !!options.tooltipHTML, }); diff --git a/src/providers/OverviewerMapProvider.ts b/src/providers/OverviewerMapProvider.ts index 96f9de5..813a6c0 100644 --- a/src/providers/OverviewerMapProvider.ts +++ b/src/providers/OverviewerMapProvider.ts @@ -18,6 +18,7 @@ */ import { + LiveAtlasAreaMarker, LiveAtlasComponentConfig, LiveAtlasDimension, LiveAtlasMarker, @@ -279,7 +280,7 @@ export default class OverviewerMapProvider extends MapProvider { marker.iconUrl = this.config + (data.icon || markerSet.icon); } - return marker as LiveAtlasMarker; + return marker as LiveAtlasMarker | LiveAtlasAreaMarker; } async loadServerConfiguration(): Promise { diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index db457f7..c5f5526 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -325,7 +325,7 @@ export default class Pl3xmapMapProvider extends MapProvider { y: 0, z: marker.point?.z || 0, }, - dimensions: marker.size ? [marker.size.x || 16, marker.size.z || 16] : [16, 16], + iconSize: marker.size ? [marker.size.x || 16, marker.size.z || 16] : [16, 16], iconUrl: `${this.config}images/icon/registered/${marker.icon || "default"}.png`, tooltip: marker.tooltip ? stripHTML(marker.tooltip) : '', diff --git a/src/util/dynmap.ts b/src/util/dynmap.ts index 674e48e..804c14e 100644 --- a/src/util/dynmap.ts +++ b/src/util/dynmap.ts @@ -349,8 +349,8 @@ function buildMarker(id: string, data: Marker, config: DynmapUrlConfig): LiveAtl y: !isNaN(data.y) ? Number.isInteger(data.y) ? data.y + 0.5 : data.y : 0, z: !isNaN(data.z) ? Number.isInteger(data.z) ? data.z + 0.5 : data.z : 0, }, - dimensions: (dimensions || [16, 16]) as PointTuple, iconUrl: `${config.markers}_markers_/${data.icon || "default"}.png`, + iconSize: (dimensions || [16, 16]) as PointTuple, minZoom: typeof data.minzoom !== 'undefined' && data.minzoom > -1 ? data.minzoom : undefined, maxZoom: typeof data.maxzoom !== 'undefined' && data.maxzoom > -1 ? data.maxzoom : undefined, tooltip: data.markup ? stripHTML(data.label) : data.label, diff --git a/src/util/points.ts b/src/util/points.ts index b3e26dc..acad10f 100644 --- a/src/util/points.ts +++ b/src/util/points.ts @@ -54,7 +54,7 @@ export const updatePointLayer = (marker: Marker | undefined, options: LiveAtlasP icon.update({ iconUrl: options.iconUrl, label: options.tooltipHTML || options.tooltip, - iconSize: options.dimensions, + iconSize: options.iconSize, isHtml: !!options.tooltipHTML, }); }