Mapbox-gl-native: Callout sticks to edge of screen when panning quickly

Created on 8 Feb 2017  路  10Comments  路  Source: mapbox/mapbox-gl-native

Platform: iOS 10.2
Mapbox SDK version: 3.4.1

With the merged PR https://github.com/mapbox/mapbox-gl-native/pull/6676 into 3.4.0, the callout stays open, but I experience a weird bug, see the following gif:

out

(BTW: Can I somehow disable that the callout should stay open?)

annotations bug iOS

All 10 comments

I'm not able to reproduce this. Perhaps you could leave some code showing your implementation of the annotation?

Further, it appears that you can implement the MGLCalloutView protocol to customize the dismissal of the callout, i.e. dismissesAutomatically

Yes of course. I open the callout manually in code like this

func showCallout(at location: CLLocationCoordinate2D, title: String) {
  let annotation = MGLPointAnnotation()
  annotation.title = title
  annotation.coordinate = location
  mapView.addAnnotation(annotation)
  mapView.selectAnnotation(annotation, animated: true)
}

With the code you provided, I'm still unable to reproduce your issue in the simulator as well as on device with the default annotation view. Perhaps the issue has to do with your custom annotation image implementation.

If you don't mind, you could just share the repo with me privately and I could take a look and run the project on my device and see what's going on.

Hi Adam,

I'm going to share the repo with you, could you please give me some contact information (Telegram, WhatsApp, Slack) so that we can talk about this issue and the setup of the repo (you have to do a few things I can explain to you quickly). I don't have a custom annotation image nor do I have left/right callout accessories (I have, but I commented them out and the error still occurs).

I appreciate your help, thanks!

For people struggling with the same problem: I temporarily fixed this issue with this little workaround. Even though it is called every time the region is changing, it doesn't affect performance.

func mapViewRegionIsChanging(_ mapView: MGLMapView) {
  if mapView.visibleAnnotations == nil, let annotations = mapView.annotations {
    mapView.removeAnnotations(annotations)
  }
}

@adampitchie Could you contact me by email once you have time?

@rmnblm sure

We update the callout view (either repositioning or dismissing it) on the mbgl::MapChangeRegionWillChange, mbgl::MapChangeRegionWillChangeAnimated, mbgl::MapChangeDidFinishRenderingFrame, and mbgl::MapChangeDidFinishRenderingFrameFullyRendered events. After panning quickly, the annotation goes out of view during a drift animation, during which we get mbgl::MapChangeRegionIsChanging events followed by a final mbgl::MapChangeRegionDidChangeAnimated event. I鈥檓 not sure why we wouldn鈥檛 get getting mbgl::MapChangeDidFinishRenderingFrame in this case, so that鈥檚 something to look into.

I think we should consider modifying -notifyMapChange: to instead call -updateCalloutView on mbgl::MapChangeRegionIsChanging, mbgl::MapChangeRegionDidChange, and mbgl::MapChangeRegionDidChangeAnimated, as the macOS SDK implementation does. (The macOS SDK doesn鈥檛 quite have the same case, however, because drifting is driven by AppKit instead of an mbgl transition.)

Can I somehow disable that the callout should stay open?

If you create a custom callout view, it is possible to set dismissesAutomatically to YES (#7646). However, there isn鈥檛 a way to control the dismissal behavior for standard callout views. If you consider this option to be important, please open a separate issue.

@frederoni points out that #8022 fixed this issue. 馃帀

The fix in #8022 can be tested using the latest iOS beta currently 3.5.0 beta 2

Awesome, thanks!

Was this page helpful?
0 / 5 - 0 ratings