-5

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

Jagdeep Singh
  • 2,436
  • 3
  • 17
  • 27

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,274
  • 2
  • 26
  • 33