简体   繁体   English

如何在iOS mapKit中达到最大缩放级别?

[英]How do I achieve the maximum zoom level in iOS mapKit?

I'm aware of this post: How to get to the max zoomlevel on iOS MKMapView 我知道这篇文章: 如何在iOS MKMapView上达到最大zoomlevel

And it seems to be exactly what I need to solve the problem, however, the technique does not work for me. 似乎正是我需要解决的问题,但是,该技术对我不起作用。

If I set the eyeAltitude at 50, or even 100, I get the same map zoom returned. 如果将eyeAltitude设置为50,甚至100,我将返回相同的地图缩放。 However, once the map is displayed, I can pinch to zoom to the desired zoom level. 但是,一旦显示了地图,我就可以捏放大到所需的缩放级别。 is there a solution to programmatically achieve the pinched in zoom level at the initial load of the map view? 是否有解决方案以编程方式在地图视图的初始加载时达到缩放级别?

EDIT: I've tried using setRegion but the problem seems to be related to using .satelliteFlyover specifically. 编辑:我曾尝试使用setRegion,但问题似乎与专门使用.satelliteFlyover有关。 I need to use .satelliteFlyover due to the difference in image quality. 由于图像质量的差异,我需要使用.satelliteFlyover。 Further EDIT: I've also discovered that the simulator seems to give a different 'native zoom' than when it runs on my device. 进一步的编辑:我还发现模拟器似乎提供了与在设备上运行时不同的“自然缩放”。 I hope someone reads this that can provide insight!! 我希望有人读这篇可以提供洞察力的东西!!

the code I'm using is: 我正在使用的代码是:

let greenLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(CLLocationDegrees(greenX),CLLocationDegrees(greenY))
        let altitude:CLLocationDistance = 80
        self.greenMap.mapType = .satelliteFlyover
        let camera = MKMapCamera(lookingAtCenter: greenLocation, fromEyeCoordinate: greenLocation, eyeAltitude: altitude)
        self.greenMap.setCamera(camera, animated: true)

You can set region to make map view scale to fit. 您可以设置区域以使地图视图比例合适。 Use this function. 使用此功能。

open func setRegion(_ region: MKCoordinateRegion, animated: Bool)

Here is the sample code. 这是示例代码。

let map = MKMapView()
let center = CLLocationCoordinate2D(latitude: 115, longitude: 24)
let span = MKCoordinateSpan(latitudeDelta: 0.003, longitudeDelta: 0.003)
let region = MKCoordinateRegion(center: center, span: span)
map.setRegion(region, animated: false)

I solved this by... using a different SDK for mapping. 我通过...使用其他SDK进行映射来解决此问题。 What I found through continued testing is that appleMaps doesn't always have the imagery down to the specific zoom level, and seems to get tripped up when you zoom in ultra close. 通过持续测试,我发现appleMaps并不总是将图像缩小到特定的缩放级别,并且当您超近放大时似乎会绊倒。 on some locations it would zoom perfectly, and others it would not - an inconsistency that as a developer you may want to be weary of. 在某些位置它会完美缩放,而在另一些位置则无法缩放-这是您可能想厌倦的开发人员的不一致之处。 googleMap had higher quality imagery and no issues with zoom consistency. googleMap的图像质量更高,并且缩放一致性没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM