MapMarkerCluster (API Reference)
Class MapMarkerCluster
Groups map markers and enables their clustering to reduce visual clutter when there are many of them in a small area.
The markers that are close to each other are replaced by a single cluster marker. Cluster groups are generated based on geographical distance between objects, not based on screen space collision. Hence it is possible, that cluster markers can overlap.
The markers can be added to a cluster or to a scene, but not to both. To display the cluster on the
map, add it to the scene using MapScene.addMapMarkerCluster(com.here.sdk.mapview.MapMarkerCluster). The display of a cluster is only
guaranteed in case its origin is within the viewport. At the moment, this is a known limitation
that mostly affects clusters which are visually large and cover a sizeable part of the viewport.
Markers part of the cluster with opacity set to zero are still on the map and are considered for picking and clustering.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classStyling options for a marker cluster which is represented by the marker count as a text.static final classRepresents a group of map markers belonging to a cluster.static final classThis class specifies the visual appearance of a cluster marker. -
Constructor Summary
ConstructorsConstructorDescriptionMapMarkerCluster(MapMarkerCluster.ImageStyle imageStyle) Creates a new instance of a map marker cluster which is represented as an image.MapMarkerCluster(MapMarkerCluster.ImageStyle imageStyle, MapMarkerCluster.CounterStyle counterStyle) Creates a new instance of a map marker cluster which is represented as an image along with a counter showing how many markers are actually grouped under particular cluster icon. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMapMarker(MapMarker marker) Adds a map marker to this cluster.voidaddMapMarkers(List<MapMarker> markers) Adds a list of map markers to this cluster.Returns the list of map markers which currently belong to this cluster.doubleGets the current opacity of the marker cluster image.voidRemoves all map markers from this cluster.voidremoveMapMarker(MapMarker marker) Removes a map marker from this cluster.voidremoveMapMarkers(List<MapMarker> markers) Removes a list of map markers from this cluster.voidsetOpacity(double value) Sets the opacity of the marker cluster image.
-
Constructor Details
-
MapMarkerCluster
Creates a new instance of a map marker cluster which is represented as an image.
Any modification to object passed as
imageStyleafter creation ofMapMarkerClusterdoes not have any effect.- Parameters:
imageStyle-The visual representation for the cluster.
-
MapMarkerCluster
public MapMarkerCluster(@NonNull MapMarkerCluster.ImageStyle imageStyle, @NonNull MapMarkerCluster.CounterStyle counterStyle) Creates a new instance of a map marker cluster which is represented as an image along with a counter showing how many markers are actually grouped under particular cluster icon.
Any modification to
imageStyleorcounterStyleafter creation ofMapMarkerClusterdoes not have any effect.- Parameters:
imageStyle-Describes the visual appearance of cluster icon.
counterStyle-Describes the appearance of marker count label.
-
-
Method Details
-
addMapMarker
Adds a map marker to this cluster. Adding a marker which is already part of the cluster or which was already added to the map scene has no effect.
- Parameters:
marker-The marker.
-
addMapMarkers
Adds a list of map markers to this cluster.
Markers which are already part of the cluster or which were already added to the map scene will be ignored.
- Parameters:
markers-The list of markers.
-
removeMapMarker
Removes a map marker from this cluster.
Removing a marker which is not part of this cluster has no effect.
- Parameters:
marker-The marker.
-
removeMapMarkers
Removes a list of map markers from this cluster.
Removing markers which are not part of this cluster has no effect.
- Parameters:
markers-The list of markers.
-
removeAllMapMarkers
public void removeAllMapMarkers()Removes all map markers from this cluster.
-
getMarkers
Returns the list of map markers which currently belong to this cluster.
Modifying the list has no effect on the marker cluster.
- Returns:
The list of map markers which currently belong to this cluster.
-
getOpacity
public double getOpacity()Gets the current opacity of the marker cluster image.
- Returns:
Opacity is the factor which is applied to the alpha channel of the image used for marker cluster.
-
setOpacity
public void setOpacity(double value) Sets the opacity of the marker cluster image.
Provided value is clamped in range [0.0, 1.0]. Default value is 1.0 which means marker cluster is displayed with the default opacity of the image.
Marker clusters with opacity value set to 0.0 are still on the map and are considered for picking.
Markers part of cluster will use their respective opacity when not displayed as a cluster icon.
- Parameters:
value-Opacity is the factor which is applied to the alpha channel of the image used for marker cluster.
-