如何解决MKMapSnapshotter 不返回确切区域
给定一个特定的区域,我想获得一张地图图像,我正在使用 Swift MKMapSnapshotter 进行此操作。图像很受欢迎,但是当我使用 snapshot.point
函数根据角坐标找到正确的像素时,它并没有完全给出图像的角,这是怎么回事?
let region = myMap.region
let options = MKMapSnapshotter.Options()
options.size = myMap.frame.size
options.region = region
var snapshotter = MKMapSnapshotter(options: options)
snapshotter.start { [self] snapshot,error in
guard let snapshot = snapshot else {
print("Snapshot error: \(error!)")
return
}
let corner1=CLLocationCoordinate2D(latitude: region.center.latitude-region.span.latitudeDelta/2,longitude: region.center.longitude-region.span.longitudeDelta/2)
let corner2=CLLocationCoordinate2D(latitude: region.center.latitude+region.span.latitudeDelta/2,longitude: region.center.longitude+region.span.longitudeDelta/2)
print(snapshot.image.size)
print("point:\(snapshot.point(for: corner1))")
print("point:\(snapshot.point(for: corner2))")
}
收到的结果(四舍五入以提高可读性):
(802.0,722.0)
point:(0,101)
point:(802,734)
预期结果:
(802.0,**0**)
point:(**801**,**721**)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。