I have this code to open Google Maps App with specific location and it\'s working but what I need is to drop a pin on that location, is it possible ?
if (UIA
if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
UIApplication.shared.open(URL(string: "comgooglemaps://?center=\(self.latitude),\(self.longitude)")!, options: [:], completionHandler: nil)
} else {
print("Opening in Apple Map")
let coordinate = CLLocationCoordinate2DMake(self.latitude, self.longitude)
let region = MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(0.01, 0.02))
let placemark = MKPlacemark(coordinate: coordinate, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
let options = [
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: region.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: region.span)]
mapItem.name = theLocationName
mapItem.openInMaps(launchOptions: options)
}
Use this code for opening in google map if it's installed else open in default apple map.