MarkerCollection
A MarkerCollection provides methods to manage Marker instances on an associated Floor. The API is accessed via the Floor.markers() method on a Floor instance.
map.on("ready", function() {
// Create a MarkerCollection instance via `floor.markers()`, which can only be
// called once the map has loaded. In this example, we add a marker to the
// map's first floor.
var markers = map.floors().first().markers();
var myMarker = markers.add({
id: "my-marker",
translate: [200, 200],
cursor: "pointer",
draggable: false,
size: [64, 64],
icon: {
url: "https://cdn.sightmap.com/app/icons/markers/pin-star.svg",
size: [512, 512],
// Set the anchor point to bottom center of the icon.
anchor: [256, 512],
},
hitarea: null,
});
});MarkerCollection.add(marker)
Adds a Marker instance to a Floor. The marker object is defined below.
Marker Object
| Key | Required | Type | Default Value | Description |
|---|---|---|---|---|
| icon | Yes | Object | undefined | The marker's icon. See Marker.icon() for further details and usage examples. |
| id | No | String | undefined | An identifier for the marker instance. Example: 1 or my-marker. |
| translate | No | Array | [0, 0] | The marker's initial position in map space. Example: [20, 20]. |
| size | No | Array | undefined | The marker's initial size in map space: Example: When no value is provided, the size will be set based on the |
| draggable | No | Boolean | false | Determines whether or not the marker can be dragged by the user. Example: false. |
| hitarea | No | Object | undefined | Defines the interactive region of the marker. When no value is provided, the See Marker.hitarea() for further details and usage examples. |
Returns
The created Marker instance.
MarkerCollection.removeAll()
Removes all Marker instances from the Floor.
Removing a single markerTo remove a single marker, call the
remove()method on a given Marker instance.
Returns
The object chain.
Updated 3 days ago
