-5

How to open native ios map application by adding pin at specific lat and lng from Objective C.

Jagdeep Singh
  • 2,556
  • 3
  • 18
  • 28

1 Answers1

0

And for Swift 3 and swift 4

let apiKey = "https://www.google.com/maps/dir/" + userCurrentLocation.coordinate.latitude + "," + userCurrentLocation.coordinate.longitude + "/" + nextCurrentLocation.coordinate.latitude + "," + nextCurrentLocation.coordinate.longitude

var url = URL(string: apikey)
UIApplication.shared.open(openUrl!, options: [:]) { (res:Bool) in

            }

For objective c use

 NSString *apikey = [NSString stringWithFormat:@"https://www.google.co.in/maps/dir/%f,%f/%f,%f",userCurrentLocation.coordinate.latitude,userCurrentLocation.coordinate.longitude,nextCurrentLocation.coordinate.latitude,nextCurrentLocation.coordinate.longitude;

NSURL *url = [NSURL URLWithString:apikey];

[[UIApplication sharedApplication] openURL:url];
Bijender Singh Shekhawat
  • 3,934
  • 2
  • 30
  • 36