Rename GenericMarker dimensions to iconSize and make optional

This commit is contained in:
James Lyne 2022-02-24 21:08:27 +00:00
parent 2a47a99493
commit 87a1665d53
7 changed files with 9 additions and 8 deletions

2
src/index.d.ts vendored
View File

@ -217,8 +217,8 @@ interface LiveAtlasMarker {
interface LiveAtlasPointMarker extends LiveAtlasMarker {
type: LiveAtlasMarkerType.POINT;
dimensions: PointTuple;
iconUrl: string;
iconSize?: PointTuple;
}
interface LiveAtlasPathMarker extends LiveAtlasMarker {

View File

@ -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],

View File

@ -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,
});

View File

@ -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<void> {

View File

@ -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) : '',

View File

@ -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,

View File

@ -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,
});
}