mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Custom annotation view floating on HStack or Stack issue

Open Asheshp23 opened this issue 3 years ago • 3 comments

Environment

  • Xcode version: 13.4.1
  • iOS version: 15.5
  • Devices affected: iPad
  • Maps SDK Version: 10.5.0

Observed behavior and steps to reproduce

Custom annotation view is floating over the HStack or VStack when user panning around on the map.

Expected behavior

Custom annotation view should not float over the HStack or VStack when user panning around on the map.

Asheshp23 avatar Jul 12 '22 16:07 Asheshp23

@Asheshp23, can you please provide a video of the behavior you're experiencing?

ZiZasaurus avatar Sep 12 '22 12:09 ZiZasaurus

https://user-images.githubusercontent.com/22404192/189655149-3458697d-1905-4c00-94a8-89cf0fa9af1c.MOV

Asheshp23 avatar Sep 12 '22 12:09 Asheshp23

This is how i am adding the custom annotationView

let options = ViewAnnotationOptions(
      geometry: Point(coordinate),
      allowOverlap: true,
      anchor: .center
    )
    mapView.viewAnnotations.removeAll()

    let customAnnotationView = UIHostingController(rootView: AnnotationView(text: name))
    customAnnotationView.view.frame =  CGRect(x: 0, y: 0, width: 200, height: 200)
    customAnnotationView.view.backgroundColor = .clear

    try? mapView.viewAnnotations.add(customAnnotationView.view, options: options)

    // move annotationView up so that it will not cover the point annotation
    try? mapView.viewAnnotations.update(customAnnotationView.view, options: ViewAnnotationOptions(offsetY: 30.0))

Asheshp23 avatar Sep 12 '22 13:09 Asheshp23

@Asheshp23, thank you for reporting this. Are you able to use UIViews instead for your ViewAnnotations?

ZiZasaurus avatar Nov 16 '22 18:11 ZiZasaurus

Closing this ticket, but please feel free to reopen if you have any additional questions related to this issue.

ZiZasaurus avatar Dec 06 '22 16:12 ZiZasaurus