December 2016
Intermediate to advanced
456 pages
8h 46m
English
In this chapter, we will have a look at some awesome updates to the MapKit and CoreLocation frameworks.
You have a latitude and a longitude of a location on Earth that you would like to display as a pin on the map.
Follow these steps:
MapKit as a framework into your project.NSObject and MKAnnotation. Conforming to the MKAnnotation protocol requires defining its variables—particularly coordinate, title, and subtitle—and methods. Instances of classes that conform to MKAnnotation can be added to the map view via its addAnnotation(_:) method.MKCoordinateSpan with a latitude delta and longitude delta of type double. The smaller the deltas, the closer the camera is to the earth.MKCoordinateRegion with the location you want to be the center of the map, and pass the coordinate span instance that you created in the previous step to the coordinate region.addAnnotation(_:) method of your map view to set the annotation at the right spot.setRegion(_:animated:) method of your map view to set the visible region of your map.Let’s have a look at an example. Create a single view application in Xcode and open the Main.storyboard file in Interface Builder. From the Object ...