How to display entire globe in MKMapView

2019-07-14 02:36发布

I am working on a map app and I want to enable user to zoom out to entire globe. I am using MKMapView. I saw that this feature is available in iOS map app.

Can anyone tell how can I achieve the same in my app.

iPhone Map App Screenshot

3条回答
Deceive 欺骗
2楼-- · 2019-07-14 02:43

According to one of Apple's technical support staff, it appears that this view is not accessible using MapKit:

This view is not available through MapKit.

https://forums.developer.apple.com/thread/101479

查看更多
男人必须洒脱
3楼-- · 2019-07-14 02:49

Change the map to Hybrid Flyover or Satellite Flyover and Enable 3D View from storyboard

Call this function from viewDidLoad updateMapToShowGlobe(location: mapView.centerCoordinate)

// MARK: Snippet to show full globe in 3d view
private func updateMapToShowGlobe(location :CLLocationCoordinate2D) {
    let span = MKCoordinateSpanMake(130, 130)
    let region = MKCoordinateRegionMake(location, span)
    if( region.center.latitude > -90 && region.center.latitude < 90 && region.center.longitude > -180 && region.center.longitude < 180 ){
        mapView.setRegion(region, animated: true)
    }
}
查看更多
Rolldiameter
4楼-- · 2019-07-14 02:55

It's like so sad since there have been so wrong informations down below.
It's so easy to do at least in iOS 12, November 2018.

That's all you need to do to get globe view.

either

mapView.mapType = .satelliteFlyover 

or

mapView.mapType = .hybridFlyover

(I am not sure and it has no technical basis but it feels like .hybridFlyover shows better performance in my experience)

That's all though :p;;
I make sure it works because I did it right before.

I hope you find it useful.

查看更多
登录 后发表回答