-
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Issue
Related, but not specifically addressed in Issue #75 is the on appear camera behavior. When launching the MapView with a specific camera state, there's a synchronization issue (this may be in the underlying maplibre-native iOS implementation).
If the MapViewCamera is user tracking when the MapView is created, the map may start centered at 0.0, 0.0 and fly to the user location. The expected behavior is the MapView immediately renders the tracking mode and zoom level.
Mitigations
To correctly launch the MapView directly into user tracking, you can:
- Set tracking in the
.onStyleLoadedcallback modifier. This properly synchronizes something in the underlying MapView such that the camera will immediately appear to be tracking. This may not seamlessly start the MapView's camera, but often does. If not, step 2 may be needed. - You can use the
MapViewProxyview modifier to generated a cached camera with a MapViewCamera.centered state. In this case, you effectively create the MapView with the camera centered on the last proxy update (last visual state). Immediately after launching the MapView.
Potential Solutions
- Correcting any erroneous lock behavior. This library may be improperly allowing a camera position of centered to sneak back to the camera @binding in certain cases. Think if the defer in here is completing before a camera animation completes (MapViewCoordinator.swift#L57)[https://github.com/maplibre/swiftui-dsl/blob/689d0a26077b3c70f490c2b2507cbcdd1eb2f8b2/Sources/MapLibreSwiftUI/MapViewCoordinator.swift#L57].
- If option 1 fails, or there is something in native making this tricky to correct. We could consider an improved camera caching wrapper. Something that captures the proxy, caches correctly and gives the map view what it needs to resume state. This is a bad solution, but may offer a solid workaround for most developers.
- Lastly, MapViewCamera Improvements #75 may offer a path forward through other means. Though I'd expect we still need to solve this issue to succeed with that issue.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working