(Re: Mapbox for Swift) I implemented a custom callout view using the example on the Mapbox website (https://www.mapbox.com/ios-sdk/examples/custom-callout/). When the annotation is near the edge of the screen, the default callout view will adjust its x-value position accordingly so that the callout will fit entirely within view. One way that this feature can be replicated in the custom callout view is by applying an adjustment (if needed) when setting the frame of self
(the callout view itself):
self.frame = CGRect(x: frameOriginX + adjustmentX, y: frameOriginY, width: frameWidth, height: frameHeight)
In the present callout delegate method:
func presentCallout(from rect: CGRect, in view: UIView, constrainedTo constrainedView: UIView, animated: Bool)
However, the custom callout, when doing this, will revert its position back to center above rect
(the annotation view) when the user begins panning (or even touches the map or another annotation). In the default callout view, however, when the user pans the map, the adjustment applied to the callout view remains.
Therefore, how do you properly adjust the custom callout view's x-value position and preserve it as the user pans the map?