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>>
- java.lang.Object
-
- org.maplibre.android.plugins.annotation.AnnotationManager<L,T,S,D,U,V>
-
- Type Parameters:
T- type of annotationS- type of options for building the annotation, depends on generic TD- type of annotation drag listener, depends on generic TU- type of annotation click listener, depends on generic TV- 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.ObjectGeneric AnnotationManager, can be used to create annotation specific managers.
-
-
Field Summary
Fields Modifier and Type Field Description protected androidx.collection.LongSparseArray<T>annotationsprotected org.maplibre.android.plugins.annotation.CoreElementProvider<L>coreElementProviderprotected org.maplibre.android.style.sources.GeoJsonSourcegeoJsonSourceprotected Llayerprotected org.maplibre.android.maps.MapLibreMapmaplibreMap
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnnotationManager(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 voidaddClickListener(U u)Add a callback to be invoked when a symbol has been clicked.voidaddDragListener(D d)Add a callback to be invoked when an annotation is dragged.voidaddLongClickListener(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.Tcreate(S options)Create an annotation on the mapvoiddelete(java.util.List<T> annotationList)Deletes annotations from the map.voiddelete(T annotation)Delete an annotation from the map.voiddeleteAll()Deletes all annotations from the map.java.lang.StringgetAboveLayerId()androidx.collection.LongSparseArray<T>getAnnotations()Get a list of current annotations.java.lang.StringgetBelowLayerId()java.lang.StringgetLayerId()Returns a layer ID that annotations created by this manager are laid out on.voidonDestroy()Cleanup annotation manager, used to clear listenersvoidremoveClickListener(U u)Remove a previously added callback that was to be invoked when symbol has been clicked.voidremoveDragListener(D d)Remove a previously added callback that was to be invoked when an annotation has been dragged.voidremoveLongClickListener(V v)Remove a previously added callback that was to be invoked when symbol has been long clicked.protected abstract voidsetDataDrivenPropertyIsUsed(java.lang.String property)voidupdate(java.util.List<T> annotationList)Update annotations on the map.voidupdate(T annotation)Update an annotation on the map.voidupdateSource()Trigger an update to the underlying source.
-
-
-
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)orStyle.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
-
-