Maps SDK for Web
Class L.TomTomMarkersLayer
This class allows you to add markers to the map. You can specify your own markers or add custom ones.
Constructor
L.TomTomMarkersLayer(options)
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options | Yes | Object | None |
Methods
addMarkers( ): L.TomTomMarkersLayer Chainable
Adds markers to the layer using the options specified by setMarkerOptions and setPopupOptions.
Please remember to add this layer instance into the map after call this method if you want to visualize markers on the map.
Returns
clearLayers( ): L.TomTomMarkersLayer Chainable
Removes all added markers
Returns
getMarkers( ): Array
setMarkerOptions(options): L.TomTomMarkersLayer Chainable
Sets the marker options which will be used by the addMarkers method.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options | Options for marker. | Yes | Object | None |
options.useBlackIcons | If set to true, default icons will be black, else they will be white. | No | Boolean | false |
options.icon | Function that will be called for every point (passed as the first argument). Should return an instance of L.Icon or any class that extends L.Icon (e.g. L.SvgIcon). | Yes | Function | None |
options.noMarkerClustering | If is set to true the markers will not be clustered and the returned marker's layer will be a L.FeatureGroup. If is set to false the markers will be clustered and the returned marker's layer will be a L.MarkerClusterGroup. | Yes | Boolean | None |
options.disableClusteringAtZoom | If marker clustering is turned on which zoom level should it be turned off. | No | Number | 17 |
options.removeOutsideVisibleBounds | If marker clustering is turned on determines if markers which are outside of viewport should be removed. | No | Boolean | false |
options.entryPoints | options for viewing entry points of added markers (if not provided entry points will not be visualized) | Yes | Object | None |
options.entryPoints.addCounterToMainPoint | if set to true, marker with entry points will have counter | No | Boolean | false |
options.maxClusterRadius | The maximum radius that a cluster will cover from the central marker (in pixels). | Yes | Number | None |
options.showCoverageOnHover | When mouse is over a cluster it shows the bounds of its markers. | Yes | Boolean | None |
options.spiderfyOnMaxZoom | When user click a cluster at the bottom zoom level it is spiderfied it. | Yes | Boolean | None |
Returns
setMarkersData(points): L.TomTomMarkersLayer Chainable
Sets the markers data which will be used by the addMarkers method.
This method expects an array of points returned by one of our search calls (e.g. fuzzySearch), or an array of simple points e.g. [[52.005, 25.01], [57.12, 12.06]].
var map = L.map('map', {key: "<YOUR_API_KEY"});
var markers = new L.TomTomMarkersLayer().addTo(map);
markers.setMarkersData([[52.005, 25.01], [57.12, 12.06]]);
markers.addMarkers();
map.fitBounds(markers.getBounds());
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
points | Array of markers data to be used by addMarkers method | Yes | Array | None |
Returns
setPopupOptions(options): L.TomTomMarkersLayer Chainable
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options | Options for popup. | Yes | Object | None |
options.popupHoverContent | Function which will be called for every point (passed as first argument). It allows you to configure the popup's behavior that appears when the cursor moves over the marker. Function must return a string. | Yes | Function | None |
options.popupContent | Function which will be called for every point (passed as first argument). It allows to configure popup content of every marker. This function should return a HTMLElement, String or Leaflet Popup element. | Yes | Function | None |
options.enableRoutingActions | Enables routing actions ("Route from", "Route to", etc.) being shown in a popup | No | Boolean | false |
options.enableSearchActions | Enables search actions ("Search nearby")being shown in a popup | No | Boolean | false |
options.entryPoints.popupHoverContent | function which will be called for each entry point to create title (visible while hovering over marker). Passed parameters (entry, point) | Yes | Function | None |
options.entryPoints.popupContent | function which will be called for each entry point to create popup for it. Passed parameters (entry, point) | Yes | Function | None |
Returns