Overviewer spawn marker
This commit is contained in:
parent
29bbc1cd76
commit
bf300d977c
1
src/index.d.ts
vendored
1
src/index.d.ts
vendored
@ -219,6 +219,7 @@ interface LiveAtlasPointMarker extends LiveAtlasMarker {
|
|||||||
type: LiveAtlasMarkerType.POINT;
|
type: LiveAtlasMarkerType.POINT;
|
||||||
iconUrl: string;
|
iconUrl: string;
|
||||||
iconSize?: PointTuple;
|
iconSize?: PointTuple;
|
||||||
|
iconAnchor?: PointTuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LiveAtlasPathMarker extends LiveAtlasMarker {
|
interface LiveAtlasPathMarker extends LiveAtlasMarker {
|
||||||
|
@ -25,6 +25,7 @@ export interface GenericIconOptions extends BaseIconOptions {
|
|||||||
isHtml?: boolean;
|
isHtml?: boolean;
|
||||||
showLabel?: boolean;
|
showLabel?: boolean;
|
||||||
iconSize?: PointTuple;
|
iconSize?: PointTuple;
|
||||||
|
iconAnchor?: PointTuple;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +118,7 @@ export class GenericIcon extends Layer implements Icon<GenericIconOptions> {
|
|||||||
if(options) {
|
if(options) {
|
||||||
this.options.iconUrl = options.iconUrl;
|
this.options.iconUrl = options.iconUrl;
|
||||||
this.options.iconSize = options.iconSize;
|
this.options.iconSize = options.iconSize;
|
||||||
|
this.options.iconAnchor = options.iconAnchor;
|
||||||
this.options.isHtml = options.isHtml;
|
this.options.isHtml = options.isHtml;
|
||||||
this.options.label = options.label;
|
this.options.label = options.label;
|
||||||
}
|
}
|
||||||
@ -128,7 +130,10 @@ export class GenericIcon extends Layer implements Icon<GenericIconOptions> {
|
|||||||
this._container!.classList.toggle('marker--auto-size', !this.options.iconSize);
|
this._container!.classList.toggle('marker--auto-size', !this.options.iconSize);
|
||||||
|
|
||||||
if(this._image) {
|
if(this._image) {
|
||||||
const iconSize = this.options.iconSize ? point(this.options.iconSize as PointExpression) : undefined;
|
const iconSize = this.options.iconSize ? point(this.options.iconSize as PointExpression) : undefined,
|
||||||
|
iconAnchor = this.options.iconAnchor ? point(this.options.iconAnchor as PointExpression) : undefined,
|
||||||
|
marginLeft = iconAnchor ? -iconAnchor.x : iconSize ? -(iconSize.x / 2) : 0,
|
||||||
|
marginTop = iconAnchor ? -iconAnchor.y : iconSize ? -(iconSize.y / 2) : 0;
|
||||||
|
|
||||||
if(iconSize) {
|
if(iconSize) {
|
||||||
this._image.width = iconSize.x;
|
this._image.width = iconSize.x;
|
||||||
@ -138,8 +143,8 @@ export class GenericIcon extends Layer implements Icon<GenericIconOptions> {
|
|||||||
this._image.removeAttribute('height');
|
this._image.removeAttribute('height');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._container.style.marginLeft = iconSize ? `${-(iconSize.x / 2)}px` : '';
|
this._container.style.marginLeft = marginLeft ? `${marginLeft}px` : '';
|
||||||
this._container.style.marginTop = iconSize ? `${-(iconSize.y / 2)}px` : '';
|
this._container.style.marginTop = marginTop ? `${marginTop}px` : '';
|
||||||
this._container.style.height = iconSize ? `${iconSize.y}px` : 'auto';
|
this._container.style.height = iconSize ? `${iconSize.y}px` : 'auto';
|
||||||
|
|
||||||
if(this._image.src !== this.options.iconUrl) {
|
if(this._image.src !== this.options.iconUrl) {
|
||||||
|
@ -34,6 +34,7 @@ export class GenericMarker extends Marker {
|
|||||||
iconUrl: options.iconUrl,
|
iconUrl: options.iconUrl,
|
||||||
label: options.tooltipHTML || options.tooltip,
|
label: options.tooltipHTML || options.tooltip,
|
||||||
iconSize: options.iconSize,
|
iconSize: options.iconSize,
|
||||||
|
iconAnchor: options.iconAnchor,
|
||||||
isHtml: !!options.tooltipHTML,
|
isHtml: !!options.tooltipHTML,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
LiveAtlasComponentConfig,
|
LiveAtlasComponentConfig,
|
||||||
LiveAtlasDimension,
|
LiveAtlasDimension,
|
||||||
LiveAtlasMarker,
|
LiveAtlasMarker,
|
||||||
LiveAtlasMarkerSet,
|
LiveAtlasMarkerSet, LiveAtlasPointMarker,
|
||||||
LiveAtlasServerConfig,
|
LiveAtlasServerConfig,
|
||||||
LiveAtlasServerMessageConfig,
|
LiveAtlasServerMessageConfig,
|
||||||
LiveAtlasWorldDefinition
|
LiveAtlasWorldDefinition
|
||||||
@ -147,8 +147,40 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.mapMarkerSets.set(tileset.path, new Map());
|
//Spawn marker
|
||||||
this.mapMarkers.set(tileset.path, new Map());
|
const markerSets = new Map<string, LiveAtlasMarkerSet>(),
|
||||||
|
markers = new Map<string, Map<string, LiveAtlasMarker>>();
|
||||||
|
|
||||||
|
if(Array.isArray(tileset.spawn)) {
|
||||||
|
markerSets.set('spawn', {
|
||||||
|
id: 'spawn',
|
||||||
|
label: tileset.poititle,
|
||||||
|
hidden: false,
|
||||||
|
priority: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const setContents = new Map<string, LiveAtlasMarker>();
|
||||||
|
|
||||||
|
setContents.set('spawn', {
|
||||||
|
id: 'spawn',
|
||||||
|
type: LiveAtlasMarkerType.POINT,
|
||||||
|
iconUrl: this.config + serverResponse?.CONST?.image?.spawnMarker,
|
||||||
|
iconSize: [32, 37],
|
||||||
|
iconAnchor: [15, 33],
|
||||||
|
tooltip: 'Spawn',
|
||||||
|
location: {
|
||||||
|
x: tileset.spawn[0],
|
||||||
|
y: tileset.spawn[1],
|
||||||
|
z: tileset.spawn[2],
|
||||||
|
}
|
||||||
|
} as LiveAtlasPointMarker);
|
||||||
|
|
||||||
|
markers.set('spawn', setContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mapMarkerSets.set(tileset.path, markerSets);
|
||||||
|
this.mapMarkers.set(tileset.path, markers);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return Array.from(worlds.values());
|
return Array.from(worlds.values());
|
||||||
|
@ -55,6 +55,7 @@ export const updatePointLayer = (marker: Marker | undefined, options: LiveAtlasP
|
|||||||
iconUrl: options.iconUrl,
|
iconUrl: options.iconUrl,
|
||||||
label: options.tooltipHTML || options.tooltip,
|
label: options.tooltipHTML || options.tooltip,
|
||||||
iconSize: options.iconSize,
|
iconSize: options.iconSize,
|
||||||
|
iconAnchor: options.iconAnchor,
|
||||||
isHtml: !!options.tooltipHTML,
|
isHtml: !!options.tooltipHTML,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user