Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

allow iOS per-frame callback #1981

Closed
tomtaylor opened this issue Aug 3, 2015 · 4 comments
Closed

allow iOS per-frame callback #1981

tomtaylor opened this issue Aug 3, 2015 · 4 comments
Labels
feature iOS Mapbox Maps SDK for iOS

Comments

@tomtaylor
Copy link

I'd like to implement a fixed scale overlay view (a CAShapeLayer) on top of a MGLMapView. One that tracks the location of the underlying coordinates and positions itself accordingly. Specifically, I want to draw a line at a fixed screen distance away from and alongside a polyline annotation.

The region change delegate methods let me do this, but they don't fire frequently enough, so the layer jitters as the map scrolls. Looking through the code I can see glkView:drawInRect:, which is used to update the user location annotation view.

Have you considered exposing an API to let me implement something similar myself? I'd consider a MGLMapView subclass, but there isn't a convenient hook into that that point in the drawInRect method.

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS labels Aug 3, 2015
@incanus
Copy link
Contributor

incanus commented Aug 17, 2015

Related: #1125

This would basically need to happen right about here in the process, between drawing the GL frame and updating the Transform, which affects pixel/geo conversions thereafter.

@incanus incanus changed the title Fixed scale overlay views allow iOS per-frame callback Aug 17, 2015
@incanus
Copy link
Contributor

incanus commented Aug 17, 2015

Also would solve #2045.

@1ec5
Copy link
Contributor

1ec5 commented Jan 26, 2016

A combination of -mapViewRegionIsChanging: and -mapView:regionDidChangeAnimated: should actually keep your view in sync with the map; if not, that’s a bug. Otherwise, you certainly could subclass MGLMapView and override -glkView:drawInRect:, but make sure to call super’s implementation in that case. (You’ll probably need to declare that your subclass conforms to GLKViewDelegate, since MGLMapView does so privately.)

@1ec5
Copy link
Contributor

1ec5 commented May 14, 2016

@tomtaylor, -[MGLMapViewDelegate mapViewDidFinishRenderingFrame:fullyRendered:] should fire frequently enough for your use case, far more reliably than -mapViewRegionIsChanging: and -mapView:regionDidChangeAnimated:. The method isn’t documented because the fullyRendered parameter doesn’t work as expected yet: #1804. As of #4801, we’re using this callback to update MGLAnnotationViews’ positions on screen as the viewport changes.

@1ec5 1ec5 closed this as completed May 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

3 participants