Class MapMarkerCluster
Class MapMarkerCluster
- java.lang.Object
-
- com.here.NativeBase
-
- com.here.sdk.mapview.MapMarkerCluster
-
public final class MapMarkerCluster extends NativeBase
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 Classes Modifier and Type Class Description static classMapMarkerCluster.CounterStyleStyling options for a marker cluster which is represented by the marker count as a text.static classMapMarkerCluster.GroupingRepresents a group of map markers belonging to a cluster.static classMapMarkerCluster.ImageStyleThis class specifies the visual appearance of a cluster marker.
-
Constructor Summary
Constructors Constructor Description MapMarkerCluster(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapMarker(MapMarker marker)Adds a map marker to this cluster.voidaddMapMarkers(java.util.List<MapMarker> markers)Adds a list of map markers to this cluster.java.util.List<MapMarker>getMarkers()Returns the list of map markers which currently belong to this cluster.doublegetOpacity()Gets the current opacity of the marker cluster image.voidremoveAllMapMarkers()Removes all map markers from this cluster.voidremoveMapMarker(MapMarker marker)Removes a map marker from this cluster.voidremoveMapMarkers(java.util.List<MapMarker> markers)Removes a list of map markers from this cluster.voidsetOpacity(double value)Sets the opacity of the marker cluster image.
-
-
-
Constructor Detail
-
MapMarkerCluster
public MapMarkerCluster(@NonNull MapMarkerCluster.ImageStyle imageStyle)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 Detail
-
addMapMarker
public void addMapMarker(@NonNull MapMarker marker)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
public void addMapMarkers(@NonNull java.util.List<MapMarker> markers)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
public void removeMapMarker(@NonNull MapMarker marker)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
public void removeMapMarkers(@NonNull java.util.List<MapMarker> markers)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
@NonNull public java.util.List<MapMarker> 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.
-
-