options to configure the ClusterTileLayer
ReadonlyidThe identifier of the Layer.
Protectedmargindefault tile margin in pixel
maximum zoom level at which data from the Layer will be displayed.
Maximum zoom level at which actual tile data is available from the data source. When the map is zoomed beyond this level, the display loads tiles at maxDataZoom and scales them up.
Same as max
minimum zoom level at which data from the Layer is displayed.
The name of the Layer
Add an EventListener to the layer. Valid events: "featureAdd", "featureRemove", "featureCoordinatesChange", "clear", "styleGroupChange", "styleChange", and "viewportReady"
The detail property of the Event gives additional information about the event. detail.layer is a reference to the layer onto which the event was dispatched and is set for all events.
A string representing the event type to listen for
the listener function that will be called when an event of the specific type occurs
Add a feature to the layer.
the feature to be added to the layer
Optionalstyle: CommonStyle[]
optional style the feature should be displayed with.
Add features to the layer.
the features to be added to the layer
Optionalstyle: CommonStyle[]
optional style the features should be displayed with.
Clears the source data provider and all associated clusters, optionally within a specified bounding box.
If no bounding box is provided, all features in the source dataProvider and all clusters will be cleared.
Optionalbbox: GeoJSONBBox
Optional. The bounding box defining the area to clear.
Clears the source data provider and all associated clusters, optionally within a specified bounding box.
If no bounding box is provided, all features in the source dataProvider and all clusters will be cleared.
Optionalbbox: GeoJSONBBox
Optional. The bounding box defining the area to clear.
OptionalclearDataProvider: booleanGet a locally cached tile by quadkey.
the quadkey of the tile
Retrieves the cluster to which the specified feature belongs at the given zoom level.
The feature for which to retrieve the cluster.
The zoom level. If not specified, the current map zoom level will be used.
The cluster feature to which the specified feature belongs, or undefined if no cluster exists.
Retrieves all clusters to which the specified feature belongs across all zoom levels. The returned array is ordered by zoom level in descending order, starting from the ClusterTileLayerOptions.clusterMaxZoom.
The feature for which to retrieve all clusters.
An array of cluster features to which the specified feature belongs, ordered by zoom level.
Retrieves the data provider associated with this ClusterTileLayer.
The data provider is responsible for supplying the features that are to be clustered and displayed within the ClusterTileLayer.
The FeatureProvider instance used by this layer.
Get provider(s) of this layer.
Get the declarative style definition of this layer.
Get styleGroup for the feature.
This method retrieves a StyleGroup for a given feature, optionally based on the specified zoom level and whether to use the layer default styles.
The feature for which to get the styles.
Optionalzoomlevel: number
The zoom level to use for determining the styles. This parameter should be set as it determines how styles are applied based on zoom. It is only optional if the style definition supports being applied without a specific zoom level.
OptionallayerDefault: boolean
(Optional) A boolean indicating whether to use the layer's default styles. If true, any custom styles set via TileLayer.setStyleGroup are ignored and the default layer styles are returned. If false, the method will return the custom styles set for the feature if available; otherwise, it returns the default layer styles. Default is false.
A readonly StyleGroup representing the styles for the given feature at the specified zoom level. If no styles are found, a falsy value is returned, indicating that the feature is not displayed/visible.
Enable or disable pointer-event triggering for all features of the layer.
Optionalactive: boolean
boolean to enable or disable posinter-events.
boolean indicating if pointer-event triggering is active or disabled.
Remove an EventListener from the layer. Valid events: "featureAdd", "featureRemove", "featureCoordinatesChange", "clear", "styleGroupChange", "styleChange", and "viewportReady"
A string which specifies the type of event for which to remove an event listener.
The listener function of the event handler to remove from the TileLayer.
Remove feature(s) from the layer.
features that should be removed from the layer
Search for feature(s) in the layer.
configure the search
search a feature by id.
Optionalonerror?: (Function to be called when a request of a "remote search" fails.
Optionalonload?: (result: Feature<string>) => voidCallback function for "remote" search.
Optionalremote?: booleanForce the data provider(s) to do remote search if no result is found in local cache.
array of features
Search for feature(s) in the layer.
configure the search
Optionalids?: number[] | string[]Array of feature ids to search.
Optionalonerror?: (Function to be called when a request of a "remote search" fails.
Optionalonload?: (result: Feature<string>[]) => voidCallback function for "remote" search.
Optionalpoint?: GeoPointGeographical center point of the circle to search in. options.radius must be defined.
Optionalradius?: numberRadius of the circle in meters, it is used in "point" search.
Optionalrect?: GeoRect | GeoJSONBBoxGeographical Rectangle to search in. [minLon, minLat, maxLon, maxLat] | GeoRect.
Optionalremote?: booleanForce the data provider(s) to do remote search if no result is found in local cache.
array of features
// searching features by id:
layer.search({ids: [1058507462, 1058507464]})
// searching by point and radius:
layer.search({
point: {longitude: 72.84205, latitude: 18.97172},
radius: 100
})
// searching by Rect:
layer.search({
rect: {minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876}
})
// remote search:
layer.search({
rect: {minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876},
remote: true, // force layer to do remote search if feature/search area is not cached locally
onload: (result) => {...}
})
Rectangle Search for feature(s) in the layer.
Geographical Rectangle to search in. [minLon, minLat, maxLon, maxLat] | GeoRect.
Optionaloptions: {configure the search
Optionalonerror?: (Function to be called when a request of a "remote search" fails.
Optionalonload?: (result: Feature<string>[]) => voidCallback function for "remote" search.
Optionalremote?: booleanForce the data provider(s) to do remote search if no result is found in local cache.
layer.search({minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876})
// or:
layer.search([72.83584, 18.96876, 72.84443,18.97299])
// remote search:
layer.search({ minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876 }, {
remote: true, // force layer to do remote search if search area is not cached locally
onload: (result) => {...}
})
Circle Search for feature(s) in the layer.
Geographical center point of the circle to search in. options.radius must be defined.
configure the search
Optionalonerror?: (Function to be called when a request of a "remote search" fails.
Optionalonload?: (result: Feature) => voidCallback function for "remote" search.
Optionalradius?: numberthe radius is mandatory for circle search.
Optionalremote?: booleanForce the data provider(s) to do remote search if no result is found in local cache.
layer.search({longitude: 72.84205, latitude: 18.97172},{
radius: 100
})
// or:
layer.search([72.84205, 18.97172], {
radius: 100
})
// remote search:
layer.search([72.84205, 18.97172], {
radius: 100,
remote: true, // force layer to do remote search if search area is not cached locally
onload: function(result){
// search result is only return in this callback function if features are not found in cache.
}
})
Search for feature by id in the layer.
id of the feature to search for
Optionaloptions: { onload?: (result: Feature) => void; remote?: boolean }
configure the search
Optionalonload?: (result: Feature) => voidCallback function for "remote" search.
Optionalremote?: booleanForce the data provider(s) to do remote search if no result is found in local cache.
Modify coordinates of a feature in the layer.
the Feature whose coordinates should be modified
the modified coordinates to set. The coordinates must match features geometry type.
Set the tile margin in pixel.
the tileMargin
Set layer with given style.
the layerStyle
keep and reuse custom set feature styles that have been set via TileLayer.setStyleGroup
Set StyleGroup the feature should be rendered with. Pass styleGroup = false|null to hide the feature. If no styleGroup is passed, custom feature style will be cleared and layer default style will be set.
the feature that's styleGroup should be set
OptionalstyleGroup: false | CommonStyle[]
the styleGroup that feature should be displayed with
Sets the visibility of the Layer.
This function controls whether the tile layer is currently displayed or hidden.
OptionalisVisible: boolean
A boolean value indicating whether the tile layer should be visible (true) or hidden (false).
The
ClusterTileLayerclass is a specialized TileLayer designed to efficiently handle clustering of GeoJSON data from various DataSources/DataProviders.This layer aggregates data points within map tiles to reduce visual clutter and improve performance, particularly when dealing with large datasets. When features are being added or removed from the DataSources, the ClusterTileLayer automatically updates to reflect the changes. Data will be clustered for each zoom level optimally from min up to clusterMaxZoom. For zoom levels below clusterMaxZoom and upto min, the untouched source data features will be displayed.
Additionally, the
ClusterTileLayersupports cluster property aggregation, allowing developers to customize how properties are aggregated when features are added or removed from the cluster. The following methods are available for property aggregation:createProperties(featureProperties: { [propertyName: string]: any }): { [propertyName: string]: any }: Creates initial properties for a cluster based on the properties of a feature.addProperties(clusterProperties: { [propertyName: string]: any }, featureProperties: { [propertyName: string]: any }): void: Updates cluster properties when a feature is added to the cluster.removeProperties(clusterProperties: { [propertyName: string]: any }, featureProperties: { [propertyName: string]: any }): void: Updates cluster properties when a feature is removed from the cluster.This layer also utilizes the ClusterFeature class to represent clusters.
See
ClusterFeature
Example