Hi,
I need to generate the image of a map at a specific resolution. I tried to use the following code:
let options = MKMapSnapshotter.Options()
options.size = CGSize(width: 300, height: 200)
options.scale = 1.0
options.mapRect = mapRect
let mapSnapshotter = MKMapSnapshotter(options: options)
if let snapshot = try? await mapSnapshotter.start() {
let image = snapshot.image
}
Since I specified the options.scale to be 1 I expect the image resolution to be exactly 300x200 pixel (and with a scale of 1). Unfortunately the resulting image has a scale factor of 3 (on an iPhone) and the actual resolution is 900x600 pixel.
I also tried, instead of using the scale option, to set the traitCollection option, like this:
options.traitCollection = UITraitCollection(displayScale: 1.0)
but I still get a 3x scale image with a resolution of 900x600.
Why is the scale option ignored? I miss something?
Thank you