Package globus.glmap

Class GLMapMarkerLayer


public class GLMapMarkerLayer extends GLMapDrawObject
Displays markers with a given style and optional clustering.

The layer can render thousands of markers efficiently and supports hit-testing in screen coordinates.

  • Constructor Details

    • GLMapMarkerLayer

      public GLMapMarkerLayer(@Nullable Object[] markers, @NonNull GLMapMarkerStyleCollection styleCollection, double clusteringRadius, int drawOrder)
      Initializes a GLMapMarkerLayer with marker objects and a style collection.
      Parameters:
      markers - Array of marker objects. Usually you set objects with data, that you need to display on map.
      styleCollection - A style collection object used to display markers.
      clusteringRadius - Radius of clustering in screen points (dp). If 0, marker clustering is disabled.
      drawOrder - Draw order used to sort objects on map.
    • GLMapMarkerLayer

      public GLMapMarkerLayer(@NonNull GLMapVectorObjectList objects, @NonNull GLMapVectorCascadeStyle cascadeStyle, @NonNull GLMapMarkerStyleCollection styleCollection, double clusteringRadius, int drawOrder)
      Initializes a GLMapMarkerLayer with vector objects and a cascade style.
      Parameters:
      objects - Array of marker objects. Usually you set objects with data, that you need to display on map.
      cascadeStyle - A cascade style that defines how markers and clusters are styled.
      styleCollection - A style collection object used to display markers.
      clusteringRadius - Radius of clustering in screen points (dp). If 0, marker clustering is disabled.
      drawOrder - Draw order used to sort objects on map.
  • Method Details

    • objectsNearPoint

      @Nullable public Object[] objectsNearPoint(@NonNull GLMapViewRenderer mapView, @NonNull MapPoint point, double distanceInPoints)
      Searches the nearest marker (or marker cluster) near a point.

      Note: the GLMapView must be attached to a surface (visible on screen) to calculate screen distances.

      Parameters:
      mapView - renderer where this layer is displayed
      point - reference point in internal map coordinates (for example, from GLMapViewRenderer.convertDisplayToInternal(double, double))
      distanceInPoints - maximum hit distance in screen points (dp)
      Returns:
      array of matched objects (a single marker or a cluster), or null if nothing is within range
    • haveObject

      public boolean haveObject(Object marker)
      Checks if given marker is added to layer
      Parameters:
      marker - marker to check
      Returns:
      true if object is in marker layer
    • modify

      public void modify(@Nullable Object[] newMarkers, @Nullable Set<Object> markersToRemove, boolean animated, @Nullable Runnable onComplete)
      Adds or removes markers on layer
      Parameters:
      newMarkers - markers that should be added
      markersToRemove - markers that should be removed
      animated - deleting or adding single markers will be animated
      onComplete - called when operation is finished
    • replace

      public void replace(@Nullable Object[] markers, @NonNull GLMapMarkerStyleCollection styleCollection, double clusteringRadius)
      Replace content with new data
      Parameters:
      markers - markers Array of marker objects.
      styleCollection - A style collection object used to display markers.
      clusteringRadius - Radius of clustering in screen points (dp). If 0, marker clustering is disabled.
    • replaceWithVectorObjects

      public void replaceWithVectorObjects(@NonNull GLMapVectorObjectList objects, @NonNull GLMapVectorCascadeStyle cascadeStyle, @NonNull GLMapMarkerStyleCollection styleCollection, double clusteringRadius)
      Replaces content with a set of vector objects and a cascade style.
      Parameters:
      objects - Array of marker objects. Usually you set objects with data, that you need to display on map.
      cascadeStyle - A cascade style that defines how markers and clusters are styled.
      styleCollection - A style collection object used to display markers.
      clusteringRadius - Radius of clustering in screen points (dp). If 0, marker clustering is disabled.
    • changeStyle

      public void changeStyle(@NonNull GLMapMarkerStyleCollection styleCollection)
      Change style of layer
      Parameters:
      styleCollection - new style for layer
    • markerIsGrouped

      public boolean markerIsGrouped(@NonNull Object marker)
      Checks if marker is part of group
      Parameters:
      marker - marker object
      Returns:
      true if marker is grouped