mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Home Page:https://mapbox.com/mobile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callout View Jumping When Panning/Zooming

Kayeee opened this issue · comments

Platform: iOS
Mapbox SDK version: 3.5

Steps to trigger behavior

  1. Make a custom Callout View using MGLCalloutView
  2. set dismissesAutomatically: Bool = false
  3. set isAnchoredToAnnotation: Bool = true

Expected behavior

Callout will stay above annotation and follow it while panning.

screen shot 2017-06-05 at 5 40 44 pm

Actual behavior

Callout drops down about 20 pixels and covers annotation when panning begins.

screen shot 2017-06-05 at 5 40 51 pm

I followed the tutorial here: and only added the dismissesAutomatically and isAnchoredToAnnotation variables. I tried setting the center of the callout view, but that didn't seem to do anything either. I also asked SO, but still no luck.

Per the docs for MGLCalloutView.anchoredToAnnotation:

You can adjust the callout view’s precise location by overriding -[UIView setCenter:].

Overriding setCenter: in your custom callout view appears to be necessary, otherwise the callout changes position. You can see an example implementation here.

This seems like something we should try handle automatically in most cases, I don’t know why it was implemented this way.

/cc @frederoni

My hunch is that the bottom arrow is out of bounds.

Overriding setCenter: for custom callout views should work as intended but bottom center should work by default as long as the frame corresponds to the actual bounds.

My hunch is that the bottom arrow is out of bounds.

In the callout view example that this issue is based on, the bounds and frame are the same size and the arrow is within them.

mapbox/ios-sdk-examples@5fd1665 has the changes to that example that needed to be made to support “sticky” callouts, happening in mapbox/ios-sdk-examples#108.

Just noticed this was still open. Merge #108 fixed it. Thanks!

This does not seem to be fixed. As soon as I removed the fix, the callout immediately dropped in front of the annotation. Am I missing something that is not displayed in the example? https://docs.mapbox.com/ios/maps/examples/custom-callout/

It's not an issue for me since the fix works well, but still.