Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way of showing MKMapView from an angle (not directly from the top) on a specific zoom level?

In swift I'm using MapKit.

I set up the outlet @IBOutlet weak var mapView: MKMapView!, used the MKMapViewDelegate, and then I'm adding some annotations.

I was wondering if there's a possibility to show my map tilted and disable changing it until user zooms out the map. So basically when he zooms in - from the specific zoom level up to the closest zoom - he would only see this:

enter image description here

instead of this:

enter image description here

and changing this option by scrolling with two fingers should be locked. When user zooms out to some specific zoom level (e.g. country-wise), then it could switch to non-3d map. Is that achievable?

like image 770
user3766930 Avatar asked Oct 18 '16 23:10

user3766930


1 Answers

Later edit:

The MKMapView has a property called camera(details here) which is an instance of MKMapCamera. You can use that property to set your desired angle. Be aware that the camera can be pitched only at certain zoom levels. Based on Apple's documentation you can check if the camera can be pitched at any given moment by checking the isPitchEnabled property on the map view object.

Original answer

Try using an instance of MKMapCamera. From the documentation that should allow you to set the desired perspective angle and zoom level by setting it's pitch, headingand altitude properties.

You can read more here.

like image 131
Mihai Fratu Avatar answered Sep 28 '22 20:09

Mihai Fratu