Scale of image generated with MKMapSnapshotter

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

My team is facing the same exact problem. We were seeing a spike in traffic when users uploaded their image positions (not a frequently used feature) but as this was a minor issue only now we are investigating this. As it turns out both options.scale = 1.0 and options.traitCollection = UITraitCollection(displayScale: 1.0) are now returning the snapshot with the same scale as the device screen, completely ignoring the option we set. Has anyone found a solution?

Scale of image generated with MKMapSnapshotter
 
 
Q