Maps Web SDK
Class L.TomTomVectorLayer
Extends | L.Class |
Category | Map |
Tile layer for Leaflet that use the vector online maps from TomTom.
The current vector renderer implementation is based on the Mapbox GL JS library.
The recommended way to use vector maps is by using the "source" option of L.Map which will create an instance if this class and immediately attach it to the newly created map instance.
Constructor
L.TomTomVectorLayer([options])
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options | It accepts all the options that Leaflet's TileLayer allows. The additional options, which are TomTom specific, are described below. | No | Object | None |
options.style | The base map style to use | No | "main" | "night" | "main" |
options.layer | The base map's layer to use | No | "basic" | "hybrid" | "labels" | "basic" |
options.vector | Options specific for vector layer | No | Object | None |
options.vector.key | API key that can be obtained from
TomTom's developer portal.
When the key is passed on the map's initialization, it is set globally for all the services.
It can be overwritten with the tomtom.key() method globally or per service
with tomtom.<service_name>.key() functions.
It is also possible to pass a specific key while working with instances of the services. |
No | String | None |
options.vector.renderer | Mapbox GL JS Map options as described in the Mapbox API Docs | No | Object | None |
options.vector.fallback | Defines the action when the browser doesn't have
support for WebGL (needed by the vector layer).
The possible values are:
- "error" will throw a javascript Error informing about the problem.
- "raster" will automatically switch to the raster layer. |
No | "error" | "raster" | "error" |
Example
// Vector layer instance with factory vector styles
var vectorLayer = new L.TomTomVectorLayer({
vector: {
key: "<Your API key>"
}
});
Methods
getStyle( ): Object
Returns the vector style object currently applied to the vector layer.
Returns
A object with the current style or undefined if no style was applied yet.
setStyle(style)
Sets the style for the vector layer.
It expects an object formatted in compliance with the Mapbox style specification.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
style | object which will be applied to vectorLayer | Yes | Object | None |
Events
To learn more about how to listen events please refer to
this documentation.
L.TomTomVectorLayer.Events.MAP_ERROR
Fired when an error occurs during the initialization of the vector layer.
L.TomTomVectorLayer.Events.STYLE_LOAD_END
Fired immediately after the style was fully loaded.