I’m working on an iOS app using MKMapView, and I need to rotate the map based on the device’s heading (orientation). However, when I use the setCamera method to update the map’s heading, it blocks user interaction with the map, such as gestures for zooming and panning.
Here’s a brief overview of what I’ve tried:
Using setCamera Method:
let camera = self.camera camera.heading = heading self.setCamera(camera, animated: true)
This approach updates the map’s heading but also blocks user interaction with the map while the camera is being set.
Using mapView.userTrackingMode = .followWithHeading
This mode does not work for my requirements because it requires user location permissions and it does not allow for customized heading adjustments without enabling location tracking.
I need a way to rotate the map’s heading based on the device’s orientation while allowing users to continue interacting with the map without interruptions.
Requirements:
- Smooth Rotation: The map should rotate smoothly based on the device’s heading.
- Non-Blocking Interaction: User interactions (zooming, panning) should remain responsive and uninterrupted.
- No User Location Tracking: The solution should work without needing to enable location tracking or permissions.