How to open maps with latitude and longitude in iOS

How to open maps with latitude and longitude in iOS
November 29, 2018 2 Comments iOS Development Pushpendra Kumar

If you are here in this post then defiantly you must be looking for the easiest way for opening the Map in iOS. I am going to tell you some simple solution with the complete methodology. Here you will get the very simple code for opening the map programmatically.

At the very first i am telling you that how to point a particular address in map via swift programming language.

func openMapForPlace() {
        let latitude: CLLocationDegrees = 37.2
        let longitude: CLLocationDegrees = 22.9
        let regionDistance:CLLocationDistance = 10000
        let coordinates = CLLocationCoordinate2DMake(latitude, longitude)
        let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance)
        let options = [
            MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate:,
            MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span)
        let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
        let mapItem = MKMapItem(placemark: placemark) = "Place Name"
        mapItem.openInMaps(launchOptions: options)

Before that you also need to import one package in your project view controller which is as…

import MapKit

After doing that, I am sure that you must have another question your mind. Here, I may be wrong. But now I am telling you how you can provide a default path in between source and destination. So let’s have look on that example.

func openMapWithPath() {
let source = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 28.7041, longitude: 77.1025))) = "Delhi INDIA"
        let destination = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 29.9671, longitude: 77.5510))) = "Saharanpur U.P. INDIA"
        MKMapItem.openMaps(with: [source, destination], launchOptions: [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving])

If you want any other tutorial reading MapKit then make your comment.

Good Luck 🙂 Happy Coding

About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd ( This website I have made so that I can meet with new challenges and can share here.
Leave Comment
  1. 1


    Hi there would you mind letting me know which webhost you’re
    using? I’ve loaded your blog in 3 completely different browsers and I
    must say this blog loads a lot quicker then most.
    Can you recommend a good hosting provider at a reasonable price?
    Cheers, I appreciate it!

  2. 1


    I am sure this paragraph has touched all the internet users,
    its really really fastidious piece of writing on building up new webpage.


Leave a reply

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