MapBox Android: ViewAnnotations rendering issue

227 views Asked by At

I have created view annotations on the Android Native MapView with Android Native MapBox SDK. It is running fine in the Android Native app.

Now when I port over that code and view implementation to the Flutter app using PlatformView, I face the annotation clipping as shown in the attached video. There are no invisible/hidden/transparent views in front of MapView.

Does anyone have idea what could be the issue here? This has to do something with the Flutter side as Native Android app has no such issues. Still you can suggest anything that could be performed on native android side to fix the issue.

The code to load the view annotations is as below

  val options = viewAnnotationOptions {
      geometry(point)
      allowOverlap(true)
      anchor(ViewAnnotationAnchor.BOTTOM)
  }
  val viewAnnotation = viewAnnotationManager.addViewAnnotation(
      // Specify the layout resource id
      resId = R.layout.layout_marker_view,
      // Set any view annotation options
      options = options
  )

Any kind of help is appreciated! Thanks.

1

There are 1 answers

0
nil On

The issue here is the platform view does not render the SurfaceView properly.

So you need to switch to TextureView using the MapInitOptions.

val mapInitOptions = MapInitOptions(
    context = context,
    resourceOptions = resourceOptionsBuilder.build(),
    mapOptions = mapOptionsBuilder.build(),
    cameraOptions = cameraOptionsBuilder.build(),
    textureView = true,
    styleUri = styleUri
)