Home > @magiclane/maps-sdk > MarkerCollection

MarkerCollection class

Marker collection class

Holds markers of a single visual style and geometry class for a map view.

Common tasks are creating a collection for a specific marker kind and adding or removing markers, looking up markers by position or identifier, iterating or counting entries, querying the collection's geographic extent for layout or hit‑testing, grouping and retrieving related components.

Can be presented on a map via the MapViewMarkerCollections object associated with a GemMapController.

Also see MarkerSketches for a specialized marker collection with per-marker render settings.

Signature:

export declare class MarkerCollection 

Constructors

Constructor

Modifiers

Description

(constructor)({ pointerId, mapId }, input)

Constructs a new instance of the MarkerCollection class

Properties

Property

Modifiers

Type

Description

area

readonly

RectangleGeographicArea

Get whole collection enclosing area.

id

readonly

number

Get collection id.

mapId

readonly

number

name

string

Get collection name.

pointerId

readonly

number | bigint

size

readonly

number

Get marker count.

type

readonly

MarkerType

Get collection type.

Methods

Method

Modifiers

Description

add(marker, index)

Add a new marker to collection.

at(index)

Get marker at a specific index (alias for getMarkerAt).

clear()

Delete all markers.

create(markerType, name)

static

Create a new marker collection.

delete(index)

Delete a marker by index.

dispose()

fromJson(json)

static

Create MarkerCollection from JSON data.

getMarkerAt(index)

Get the marker at the given index.

Return null if index is not valid.

getMarkerById(id)

Get the marker with the given id.

getPointsGroupComponents(groupId)

Gets the points group components.

This requires the collection to be added to a map view collection with MarkerCollectionRenderSettings.buildPointsGroupConfig set to true

If points group head info is not available the function will return a default list and will set the API error accordingly

getPointsGroupHead(markerId)

Gets the points group head for the given marker id.

This requires the collection to be added to a map view collection with MarkerCollectionRenderSettings.buildPointsGroupConfig set to true

If points group head info is not available the function will return null and will set the API error accordingly

If markerId is already a points group head the function will return a reference to the queried marker and will set the API error accordingly

hitTest(coordinates, ignoreMarker)

Hit test in collection markers.

indexOf(marker)

Get the index of the given marker.

init(id, mapId)

static

load(buffer)

static

Deserialize from buffer.

save()

Serialize to buffer.

toJson()

Serialize collection to JSON format.