Class: MapWaypointRenderer<W>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:183
A renderer that draws waypoints to a map. For the renderer to draw a waypoint, the waypoint must first be registered with the renderer. Waypoints may be registered under multiple render roles. Each render role is represented as a bit flag. During each render cycle, a specific role is chosen for each waypoint by a selector function. Once the role is chosen, the waypoint will be rendered in that role.
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
W extends MapWaypoint | MapWaypoint |
Constructors
Constructor
new MapWaypointRenderer<
W>(textManager,selectRoleToRender):MapWaypointRenderer<W>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:303
Creates a new instance of MapWaypointRenderer.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
textManager | MapCullableTextLabelManager | undefined | The text label manager to use for waypoint labels. |
selectRoleToRender | MapWaypointRenderRoleSelector<W> | MapWaypointRenderer.DEFAULT_RENDER_ROLE_SELECTOR | A function which selects roles under which to render waypoints. Defaults to MapWaypointRenderer.DEFAULT_RENDER_ROLE_SELECTOR. |
Returns
MapWaypointRenderer<W>
Properties
_onIconRenderEvent
protectedreadonly_onIconRenderEvent:SubEvent<MapWaypointRenderer<W>,MapWaypointIconRenderEvent<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:266
_onLabelRenderEvent
protectedreadonly_onLabelRenderEvent:SubEvent<MapWaypointRenderer<W>,MapWaypointLabelRenderEvent<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:281
_renderedIcons
protectedreadonly_renderedIcons:Map<string,MapWaypointRenderedIcon<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:231
_renderedLabels
protectedreadonly_renderedLabels:Map<string,MapWaypointRenderedLabel<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:240
onIconRenderEvent
readonlyonIconRenderEvent:ReadonlySubEvent<MapWaypointRenderer<W>,MapWaypointIconRenderEvent<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:279
An event that notifies when the rendering of an icon for a waypoint changes. Changes include when an icon is newly rendered for a waypoint, when the rendered icon changes for a waypoint, and when the icon for a waypoint is no longer rendered.
The definition of rendered used by this event is when an icon is drawn to its target canvas context. An icon that has been drawn but is not visible to the user due to downstream effects (for example, if the canvas is hidden or the drawn label is occluded by a clip path) is still considered to be rendered.
The data object passed to event handlers is only guaranteed to be valid at the moment the handler is called. If a handler needs to retain the data past this moment, then it is recommended that a copy of the data be made.
onLabelRenderEvent
readonlyonLabelRenderEvent:ReadonlySubEvent<MapWaypointRenderer<W>,MapWaypointLabelRenderEvent<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:295
An event that notifies when the rendering of a label for a waypoint changes. Changes include when a label is newly rendered for a waypoint, when the rendered label changes for a waypoint, and when the label for a waypoint is no longer rendered.
The definition of rendered used by this event is when a label is registered with the text label manager. A label that is registered with the text label manager but is not visible to the user due to downstream effects (for example, if the manager has culled the label or has not been updated to draw the label) is still considered to be rendered.
The data object passed to event handlers is only guaranteed to be valid at the moment the handler is called. If a handler needs to retain the data past this moment, then it is recommended that a copy of the data be made.
onWaypointAdded
readonlyonWaypointAdded:SubEvent<MapWaypointRenderer<W>,W>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:261
An event that notifies when a waypoint has been registered with this renderer under at least one render role.
onWaypointRemoved
readonlyonWaypointRemoved:SubEvent<MapWaypointRenderer<W>,W>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:264
An event that notifies when a waypoint has been deregistered with this renderer under all render roles.
registered
protectedreadonlyregistered:Map<string,MapWaypointRendererEntry<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:228
roleDefinitions
protectedreadonlyroleDefinitions:Map<number,MapWaypointRenderRoleDef<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:253
This renderer's render role definitions. Waypoints assigned to be rendered under a role or combination of roles with no definition will not be rendered.
roleDefinitionsArray
protectedreadonlyroleDefinitionsArray:MapWaypointRenderRoleDef<W>[] =[]
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:258
An array of this renderer's role definitions. This array is kept in sync with the roleDefinitions map.
scratchIconRenderEvent
protectedreadonlyscratchIconRenderEvent:object
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:233
icon
icon:
MapWaypointIcon<W> |undefined
renderedRole
renderedRole:
number=0
type
type:
MapWaypointRenderEventType|undefined
waypoint
waypoint:
W|undefined
scratchLabelRenderEvent
protectedreadonlyscratchLabelRenderEvent:object
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:242
label
label:
MapCullableTextLabel|undefined
renderedRole
renderedRole:
number=0
type
type:
MapWaypointRenderEventType|undefined
waypoint
waypoint:
W|undefined
selectRoleToRender
protectedreadonlyselectRoleToRender:MapWaypointRenderRoleSelector<W> =MapWaypointRenderer.DEFAULT_RENDER_ROLE_SELECTOR
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:305
A function which selects roles under which to render waypoints. Defaults to MapWaypointRenderer.DEFAULT_RENDER_ROLE_SELECTOR.
textManager
protectedreadonlytextManager:MapCullableTextLabelManager
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:304
The text label manager to use for waypoint labels.
toCleanUp
protectedreadonlytoCleanUp:Set<MapWaypointRendererEntry<W>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:229
NULL_ROLE_DEF
protectedreadonlystaticNULL_ROLE_DEF:object
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:185
A null render role definition. Icons rendered under this role are never visible.
canvasContext
canvasContext:
null=null
iconFactory
iconFactory:
null=null
labelFactory
labelFactory:
null=null
visibilityHandler()
visibilityHandler: () =>
boolean
Returns
boolean
Methods
addRenderRole()
addRenderRole(
role,def?):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:326
Adds a render role to this renderer. If the role has already been added to this renderer, this method does nothing.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | The render role to add. |
def? | MapWaypointRenderRoleDef<W> | The render role's definition. If undefined, the new role will be assigned a default definition with no defined rendering context, icon, or label factories, and a visibility handler which always returns true. |
Returns
boolean
Whether the render role was successfully added.
clearRenderRoles()
clearRenderRoles():
void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:376
Removes all render roles from this renderer.
Returns
void
deregister()
deregister(
waypoint,role,sourceId):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:506
Removes a registration for a waypoint for a specific role or roles. Once all of a waypoint's registrations for a role are removed, it will no longer be rendered in that role the next this renderer's update() method is called.
Parameters
| Parameter | Type | Description |
|---|---|---|
waypoint | W | The waypoint to deregister. |
role | number | The role(s) from which the waypoint should be deregistered. |
sourceId | string | The unique string ID for the source of the registration to remove. |
Returns
void
getNearestWaypoint()
getNearestWaypoint<
T>(pos,first?):T|undefined
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:735
Gets the nearest waypoint currently registered in the renderer.
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends MapWaypoint | W |
Parameters
| Parameter | Type | Description |
|---|---|---|
pos | LatLonInterface | The position to get the closest waypoint to. |
first? | (waypoint) => boolean | A predicate that will search the list of closest waypoints for a match, and return the first one found. |
Returns
T | undefined
The nearest waypoint, or undefined if none found.
getRenderRoleDefinition()
getRenderRoleDefinition(
role):Readonly<MapWaypointRenderRoleDef<W>> |undefined
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:360
Gets the definition for a render role.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | A render role. |
Returns
Readonly<MapWaypointRenderRoleDef<W>> | undefined
The definition for the specified render role, or undefined if no such role has been added to this renderer.
hasRenderRole()
hasRenderRole(
role):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:314
Checks whether a render role has been added to this renderer.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | The render role to check. |
Returns
boolean
Whether the render role has been added to this renderer.
isRegistered()
isRegistered(
waypoint,role?):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:460
Checks if a waypoint is registered with this renderer. A role or roles can be optionally specified such that the method will only return true if the waypoint is registered under those specific roles.
Parameters
| Parameter | Type | Description |
|---|---|---|
waypoint | W | A waypoint. |
role? | number | The specific role(s) to check. |
Returns
boolean
whether the waypoint is registered with this renderer.
register()
register(
waypoint,role,sourceId):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:484
Registers a waypoint with this renderer under a specific role or roles. Registered waypoints will be drawn as appropriate the next time this renderer's update() method is called. Registering a waypoint under a role under which it is already registered has no effect unless the source of the registration is different.
Parameters
| Parameter | Type | Description |
|---|---|---|
waypoint | W | The waypoint to register. |
role | number | The role(s) under which the waypoint should be registered. |
sourceId | string | A unique string ID for the source of the registration. |
Returns
void
removeRenderedIcon()
protectedremoveRenderedIcon(uid):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:674
Removes a rendered icon from this renderer's tracked list of rendered icons and notifies subscribers of the removal.
Parameters
| Parameter | Type | Description |
|---|---|---|
uid | string | The UID of the waypoint for the icon to remove. |
Returns
void
removeRenderedLabel()
protectedremoveRenderedLabel(uid):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:687
Removes a rendered label from this renderer's tracked list of rendered labels and notifies subscribers of the removal.
Parameters
| Parameter | Type | Description |
|---|---|---|
uid | string | The UID of the waypoint for the label to remove. |
Returns
void
removeRenderRole()
removeRenderRole(
role):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:343
Removes a render role from this renderer.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | The render role to remove. |
Returns
boolean
Whether the render role was successfully removed.
renderedIcons()
renderedIcons():
IterableIterator<Readonly<MapWaypointRenderedIcon<W>>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:540
Gets an iterable of all currently rendered waypoint icons, in no particular order.
The definition of rendered used by this method is when an icon is drawn to its target canvas context. An icon that has been drawn but is not visible to the user due to downstream effects (for example, if the canvas is hidden or the drawn label is occluded by a clip path) is still considered to be rendered.
Returns
IterableIterator<Readonly<MapWaypointRenderedIcon<W>>>
An iterable of all currently rendered waypoint icons, in no particular order.
renderedLabels()
renderedLabels():
IterableIterator<Readonly<MapWaypointRenderedLabel<W>>>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:553
Gets an iterable of all currently rendered waypoint labels, in no particular order.
The definition of rendered used by this method is when a label is registered with the text label manager. A label that is registered with the text label manager but is not visible to the user due to downstream effects (for example, if the manager has culled the label or has not been updated to draw the label) is still considered to be rendered.
Returns
IterableIterator<Readonly<MapWaypointRenderedLabel<W>>>
An iterable of all currently rendered waypoint labels, in no particular order.
renderRoles()
renderRoles():
IterableIterator<number>
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:369
Gets an iterable of render roles added to this renderer. The iterable will return the roles in the order in which they were added.
Returns
IterableIterator<number>
An iterable of render roles added to this renderer.
sendIconRenderEvent()
protectedsendIconRenderEvent(type,waypoint,renderedRole,icon):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:702
Sends an icon render event.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | MapWaypointRenderEventType | The type of the event. |
waypoint | W | The event's waypoint. |
renderedRole | number | The event's render role. |
icon | MapWaypointIcon<W> | The event's icon. |
Returns
void
sendLabelRenderEvent()
protectedsendLabelRenderEvent(type,waypoint,renderedRole,label):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:719
Sends a label render event.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | MapWaypointRenderEventType | The type of the event. |
waypoint | W | The event's waypoint. |
renderedRole | number | The event's render role. |
label | MapCullableTextLabel | The event's label. |
Returns
void
setCanvasContext()
setCanvasContext(
role,context):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:424
Sets the canvas rendering context for a render role. If the render role has not been added to this renderer, this method does nothing.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | A render role. |
context | CanvasRenderingContext2D | A canvas 2D rendering context. |
Returns
boolean
Whether the context was set.
setIconFactory()
setIconFactory(
role,factory):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:388
Sets the factory to use to create waypoint icons for a render role. If the render role has not been added to this renderer, this method does nothing.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | A render role. |
factory | MapWaypointRendererIconFactory<W> | A waypoint icon factory. |
Returns
boolean
Whether the factory was set.
setLabelFactory()
setLabelFactory(
role,factory):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:406
Sets the factory to use to create waypoint labels for a render role. If the render role has not been added to this renderer, this method does nothing.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | A render role. |
factory | MapWaypointRendererLabelFactory<W> | A waypoint label factory. |
Returns
boolean
Whether the factory was set.
setVisibilityHandler()
setVisibilityHandler(
role,handler):boolean
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:442
Sets the handler that determines if a waypoint should visible for a render role. If the render role has not been added to this renderer, this method does nothing.
Parameters
| Parameter | Type | Description |
|---|---|---|
role | number | A render role. |
handler | (waypoint) => boolean | A function that determines if a waypoint should be visible. |
Returns
boolean
Whether the handler was set.
update()
update(
mapProjection):void
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:563
Redraws waypoints registered with this renderer.
Parameters
| Parameter | Type | Description |
|---|---|---|
mapProjection | MapProjection | The map projection to use. |
Returns
void
DEFAULT_RENDER_ROLE_SELECTOR()
readonlystaticDEFAULT_RENDER_ROLE_SELECTOR<T>(entry,roleDefinitions):number
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:214
The default render role selector. For each waypoint entry, iterates through all possible render roles in the order they were originally added to the renderer and selects the first role under which the entry is registered and is visible.
Type Parameters
| Type Parameter |
|---|
T extends MapWaypoint |
Parameters
| Parameter | Type | Description |
|---|---|---|
entry | MapWaypointRendererEntry<T> | A waypoint entry. |
roleDefinitions | ReadonlyMap<number, Readonly<MapWaypointRenderRoleDef<T>>> | A map from all possible render roles to their definitions. |
Returns
number
The role under which the waypoint entry should be rendered, or 0 if the entry should not be rendered under any role.
ENTRY_SORT_FUNC()
protectedreadonlystaticENTRY_SORT_FUNC(a,b):number
Defined in: src/sdk/components/map/MapWaypointRenderer.ts:200
Sorts waypoint entries such that those with icons of higher priority are sorted after those with icons of lower priority.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | MapWaypointRendererEntry<any> | The first waypoint entry to sort. |
b | MapWaypointRendererEntry<any> | The second waypoint entry to sort. |
Returns
number
A negative number if the first entry is to be sorted before the second, a positive number if the second entry is to be sorted before the first, and zero if the entries' relative sorting order does not matter.