Hi Ed,
thank you for your answer.
I tried to specify the view of the map through an MKCoordinateRegion, and I often get the same problem (but not always). When I zoom in from a large area (say 150km per cm scale) to my small region of interest, the scale says it is 2cm to 2.5km, but if I pan around a little, the scale immediately changes to 2cm to 1.25km.
It seems to me that the scale doesn't adapt to the last zoom. In fact, if I disable the animation, when I zoom in to the small region area the map scale remains at the initial value.
let mapRegion = MKCoordinateRegion(
center: annotation.coordinate,
span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
)
setRegion(mapRegion, animated: true)
The situation improves with MKMapCamera: the scale is correct after zooming, but it only changes if I use animation.
let placemark = MKPlacemark(coordinate: annotation.coordinate)
let mapItem = MKMapItem(placemark: placemark)
let camera = MKMapCamera(
lookingAt: mapItem,
forViewSize: CGSize(
width: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE,
height: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE
),
allowPitch: false
)
setCamera(camera, animated: true)
Post
Replies
Boosts
Views
Activity
Hi Ed,
I added a simple project on GitHub to test the MKScaleView's behaviour; it is available here: https://github.com/asclepix/MapTest.git.
I noticed that if the zooming-in starts from a not so small-scale (for example 1:25.000, "Zoom Out" button in the sample), the Zoom In finishes with the right scale. If the zooming-in starts from a smaller scale ("World Zoom") the final scale is usually not the right one.
By the way, using the iOS 18 simulator, the large scale map has a red background, while it is not the case on simulators of older operating systems or on a real device with iOS 18.