1

I have different annotations (with icons) which sometimes overlap in the map. Is there any way to specify the elevation of the annotations to have some annotations always displayed over the others? As of right now it looks like there is no rule on how the annotations overlap each other, it appears to be almost random.

The annotation is created like this:

pointAnnotationManager = mapView.annotations.createPointAnnotationManager()
pointAnnotationManager.apply {
    annotationPosition = create(
        PointAnnotationsOptions()
            .withPoint(some_point)
            .withIconImage(some_bitmap)
    )
}

and updated (each second) with

annotationPosition.point = new_point
pointAnnotationManager.update(annotationPosition)

I searched the API ref. of pointAnnotationManager but did not find anything about it

lkuebler
  • 11
  • 1
  • Did you find a solution to this? How can annotations have some elevation/altitude, i.e. be displayed above the terrain. – vomi Jun 27 '23 at 08:54

1 Answers1

0

How to place one annotation above another:
when you create any AnnotationManager you can pass AnnotationConfig where you may specify belowLayerId.
To find layerId of the annotation I checked in Debug the following: annotationApi -> managerList -> referent -> layerId.
Here is my code for making a circle below the point annotation:

fun drawCircle(point: Point, radius: Double) {
        val annotationApi = mapView.annotations
        val polygonAnnotationManager =
            annotationApi.createPolygonAnnotationManager(AnnotationConfig("mapbox-android-pointAnnotation-layer-1"))
        val polygonAnnotationOptions: PolygonAnnotationOptions = PolygonAnnotationOptions()
            .withGeometry(getTurfPolygon(point, radius, circleUnit))
            .withFillColor(activity.getColor(R.color.black))
            .withFillOpacity(0.2)
        polygonAnnotationManager.create(polygonAnnotationOptions)
    }