Class AnnotationManager<L extends org.maplibre.android.style.layers.Layer,​T extends Annotation,​S extends Options<T>,​D extends OnAnnotationDragListener<T>,​U extends OnAnnotationClickListener<T>,​V extends OnAnnotationLongClickListener<T>>

  • Type Parameters:
    T - type of annotation
    S - type of options for building the annotation, depends on generic T
    D - type of annotation drag listener, depends on generic T
    U - type of annotation click listener, depends on generic T
    V - type of annotation long click listener, depends on generic T
    Direct Known Subclasses:
    CircleManager, FillManager, LineManager, SymbolManager

    public abstract class AnnotationManager<L extends org.maplibre.android.style.layers.Layer,​T extends Annotation,​S extends Options<T>,​D extends OnAnnotationDragListener<T>,​U extends OnAnnotationClickListener<T>,​V extends OnAnnotationLongClickListener<T>>
    extends java.lang.Object
    Generic AnnotationManager, can be used to create annotation specific managers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected androidx.collection.LongSparseArray<T> annotations  
      protected org.maplibre.android.plugins.annotation.CoreElementProvider<L> coreElementProvider  
      protected org.maplibre.android.style.sources.GeoJsonSource geoJsonSource  
      protected L layer  
      protected org.maplibre.android.maps.MapLibreMap maplibreMap  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AnnotationManager​(org.maplibre.android.maps.MapView mapView, org.maplibre.android.maps.MapLibreMap maplibreMap, org.maplibre.android.maps.Style style, org.maplibre.android.plugins.annotation.CoreElementProvider<L> coreElementProvider, org.maplibre.android.plugins.annotation.DraggableAnnotationController draggableAnnotationController, java.lang.String belowLayerId, java.lang.String aboveLayerId, org.maplibre.android.style.sources.GeoJsonOptions geoJsonOptions)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addClickListener​(U u)
      Add a callback to be invoked when a symbol has been clicked.
      void addDragListener​(D d)
      Add a callback to be invoked when an annotation is dragged.
      void addLongClickListener​(V v)
      Add a callback to be invoked when a symbol has been long clicked.
      java.util.List<T> create​(java.util.List<S> optionsList)
      Create a list of annotations on the map.
      T create​(S options)
      Create an annotation on the map
      void delete​(java.util.List<T> annotationList)
      Deletes annotations from the map.
      void delete​(T annotation)
      Delete an annotation from the map.
      void deleteAll()
      Deletes all annotations from the map.
      java.lang.String getAboveLayerId()  
      androidx.collection.LongSparseArray<T> getAnnotations()
      Get a list of current annotations.
      java.lang.String getBelowLayerId()  
      java.lang.String getLayerId()
      Returns a layer ID that annotations created by this manager are laid out on.
      void onDestroy()
      Cleanup annotation manager, used to clear listeners
      void removeClickListener​(U u)
      Remove a previously added callback that was to be invoked when symbol has been clicked.
      void removeDragListener​(D d)
      Remove a previously added callback that was to be invoked when an annotation has been dragged.
      void removeLongClickListener​(V v)
      Remove a previously added callback that was to be invoked when symbol has been long clicked.
      protected abstract void setDataDrivenPropertyIsUsed​(java.lang.String property)  
      void update​(java.util.List<T> annotationList)
      Update annotations on the map.
      void update​(T annotation)
      Update an annotation on the map.
      void updateSource()
      Trigger an update to the underlying source.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maplibreMap

        protected final org.maplibre.android.maps.MapLibreMap maplibreMap
      • annotations

        protected final androidx.collection.LongSparseArray<T extends Annotation> annotations
      • layer

        protected L extends org.maplibre.android.style.layers.Layer layer
      • geoJsonSource

        protected org.maplibre.android.style.sources.GeoJsonSource geoJsonSource
      • coreElementProvider

        protected org.maplibre.android.plugins.annotation.CoreElementProvider<L extends org.maplibre.android.style.layers.Layer> coreElementProvider
    • Constructor Detail

      • AnnotationManager

        @UiThread
        protected AnnotationManager​(org.maplibre.android.maps.MapView mapView,
                                    org.maplibre.android.maps.MapLibreMap maplibreMap,
                                    org.maplibre.android.maps.Style style,
                                    org.maplibre.android.plugins.annotation.CoreElementProvider<L> coreElementProvider,
                                    org.maplibre.android.plugins.annotation.DraggableAnnotationController draggableAnnotationController,
                                    java.lang.String belowLayerId,
                                    java.lang.String aboveLayerId,
                                    org.maplibre.android.style.sources.GeoJsonOptions geoJsonOptions)
    • Method Detail

      • getLayerId

        public java.lang.String getLayerId()
        Returns a layer ID that annotations created by this manager are laid out on.

        This reference can be used together with Style.addLayerAbove(Layer, String) or Style.addLayerBelow(Layer, String) to improve other layers positioning in relation to this manager.

        Returns:
        underlying layer's ID
      • getBelowLayerId

        public java.lang.String getBelowLayerId()
      • getAboveLayerId

        public java.lang.String getAboveLayerId()
      • getAnnotations

        @UiThread
        public androidx.collection.LongSparseArray<T> getAnnotations()
        Get a list of current annotations.
        Returns:
        long sparse array of annotations
      • create

        @UiThread
        public T create​(S options)
        Create an annotation on the map
        Parameters:
        options - the annotation options defining the annotation to build
        Returns:
        the build annotation
      • create

        @UiThread
        public java.util.List<T> create​(java.util.List<S> optionsList)
        Create a list of annotations on the map.
        Parameters:
        optionsList - the list of annotation options defining the list of annotations to build
        Returns:
        the list of build annotations
      • delete

        @UiThread
        public void delete​(T annotation)
        Delete an annotation from the map.
        Parameters:
        annotation - annotation to be deleted
      • delete

        @UiThread
        public void delete​(java.util.List<T> annotationList)
        Deletes annotations from the map.
        Parameters:
        annotationList - the list of annotations to be deleted
      • deleteAll

        @UiThread
        public void deleteAll()
        Deletes all annotations from the map.
      • update

        @UiThread
        public void update​(T annotation)
        Update an annotation on the map.
        Parameters:
        annotation - annotation to be updated
      • update

        @UiThread
        public void update​(java.util.List<T> annotationList)
        Update annotations on the map.
        Parameters:
        annotationList - list of annotation to be updated
      • updateSource

        public void updateSource()
        Trigger an update to the underlying source. The update is delayed until after the next UI draw to batch multiple actions.
      • setDataDrivenPropertyIsUsed

        protected abstract void setDataDrivenPropertyIsUsed​(@NonNull
                                                            java.lang.String property)
      • addDragListener

        @UiThread
        public void addDragListener​(@NonNull
                                    D d)
        Add a callback to be invoked when an annotation is dragged.
        Parameters:
        d - the callback to be invoked when an annotation is dragged
      • removeDragListener

        @UiThread
        public void removeDragListener​(@NonNull
                                       D d)
        Remove a previously added callback that was to be invoked when an annotation has been dragged.
        Parameters:
        d - the callback to be removed
      • addClickListener

        @UiThread
        public void addClickListener​(@NonNull
                                     U u)
        Add a callback to be invoked when a symbol has been clicked.
        Parameters:
        u - the callback to be invoked when a symbol is clicked
      • removeClickListener

        @UiThread
        public void removeClickListener​(@NonNull
                                        U u)
        Remove a previously added callback that was to be invoked when symbol has been clicked.
        Parameters:
        u - the callback to be removed
      • addLongClickListener

        @UiThread
        public void addLongClickListener​(@NonNull
                                         V v)
        Add a callback to be invoked when a symbol has been long clicked.
        Parameters:
        v - the callback to be invoked when a symbol is clicked
      • removeLongClickListener

        @UiThread
        public void removeLongClickListener​(@NonNull
                                            V v)
        Remove a previously added callback that was to be invoked when symbol has been long clicked.
        Parameters:
        v - the callback to be removed
      • onDestroy

        @UiThread
        public void onDestroy()
        Cleanup annotation manager, used to clear listeners