I've found that using MapCameraBounds adjusts zoom level
mapCameraBounds = MapCameraBounds(minimumDistance: minimumDistance, maximumDistance: maximumDistance)
I now want to make the changes smooth and have thought of using .onChange(of:) and withAnimation, as follows:
.onChange(of: locationManager.currentLocation?.speed) { oldValue, newValue in
withAnimation(.spring(duration: 1.0)) {
let speed = newValue ?? 0.0
if speed > 20 {
minimumDistance = 5000.0
maximumDistance = 10000.0
} else {
minimumDistance = 1000.0
maximumDistance = 2000.0
}
mapCameraBounds = MapCameraBounds(minimumDistance: newValue, maximumDistance: maximumDistance)
}
}
Map(position: $position, bounds: mapCameraBounds)
But that doesn't work, zoom changes are not animated. Is there a proper way of doing this?
Topic:
App & System Services
SubTopic:
Maps & Location
Tags: