I am using the Gooogle Url Scheme to show the directions with the press of a button in swift. How can i use the url callback scheme to get back to my app, after i have opened the native google maps app. I am using the below code
if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"comgooglemaps://")!)) {
UIApplication.sharedApplication().openURL(NSURL(string:
"comgooglemaps://?saddr=&daddr=\(place.latitude),\(place.longitude)&directionsmode=driving")!)
} else {
NSLog("Can't use comgooglemaps://");
}
}
I have tried referring to this link Google Map Url Scheme if anyone knows how to do it, pls answer with a sample swift code
You can use the OpenInGoogleMaps component provided by Google Maps. It even lets you encode a redirect URL to your App, which is displayed on top of the directions in the Google Maps application.
This is what the code looks like in Swift:
var place: CLLocationCoordinate2D
var definition = GoogleDirectionsDefinition()
definition.destinationPoint = GoogleDirectionsWaypoint(location: place)
definition.travelMode = GoogleMapsTravelMode.Driving
OpenInGoogleMapsController.sharedInstance().openDirections(definition)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.