How to Integrate Mapkit View In iOS App To Put Pins on Map

Uptil now, we all have worked with location framework to retrieve user’s location or converting coordinates into address, but still the best way to provide a location information is by adding pins on map.

The Apple’s mapkit framework provides an interface to embed maps directly into the views. In fact, the mapkit also supports for annotating, adding overlays, and performing reverse lookups to determine information for the selected location coordinate.

Mapkit is one of the neat APIs that come with iOS SDK for developers to display maps, navigate through maps, add overlays over the map. And, today, in this iOS app tutorial, we’ll have a look at mapkit implementation process by creating a simple iOS application.

Let’s Get Started

Open your Xcode and create new project under file menu.


In the next tab, select Single View Application and click on next.


Set your project name and other details.


Once you create a new project, go to Main.Storyboard and select ViewController.


Now, drag and drop MKMapView from “Show the object library” section.



Select MKMapView and see the attribute inspector which have properties of MKMapView. we can manage the zoom enable, Rotate enable, Current Location etc.


Now, set outlet MKMapView in ViewController.

@IBOutlet weak var myMap: MKMapView!


Import Mapkit in ViewController
import MapKit

To get permission for access location, we need to add key in info.plist

<string>Always use your current location.</string>


Now declare a variable of CLLocationManager to get current location and set delegate.

class ViewController: UIViewController, CLLocationManagerDelegate

var locationManager: CLLocationManager = CLLocationManager()

Now, create a function for get permission to access current location of user and call it from viewDidLoad().

override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.

func setCurrentLocation() {
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
if self.locationManager.respondsToSelector(#selector(CLLocationManager.requestAlwaysAuthorization)) {
} else {

Once user get permission then every time this method will be called to update user’s current location.

func startUpdatingLocation() {

// MARK: - CLLocationManagerDelegate

func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
if status == .AuthorizedWhenInUse || status == .AuthorizedAlways {

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last! as CLLocation

let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.20, longitudeDelta: 0.20))

self.myMap.setRegion(region, animated: true)
self.myMap.showsUserLocation = true

And done!

So by this tutorial, you’ve the basic information of Mapkit API integration process to build iOS app. However, if you’ve a mobile app idea that involves the use of map to provide certain options, it’s better to consult with an iPhone app development company or talk to expert mobile application developers to understand and determine the development flow for your mobile app idea.

Grab a free copy of mapkitview integration demo from Github.


Have an iOS App Idea in Mind? Let's Discuss!

Get your free consultation now

Leave a Reply

Your email address will not be published. Required fields are marked *

Get Your Free Quote