1. Install Google Maps app for iphone, because it will use this program to navigation
2. Where you need to go to the navigation in your app, add the following codes
if ([[UIApplication sharedapplication] Canopenurl: [nsurl urlwithstring:@ "comgooglemaps:// "]]) { [[uiapplication sharedapplication] OpenURL: [nsurl urlwithstring:@" comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic " Else { NSLog (@ "Can ' t use comgooglemaps://" );}
If the main thing here is to determine if there is a Google Map app in your phone. If you have one, upload the URL to the Google Mao app.
For example:
Comgooglemaps://? center=46.414382,10.013988&mapmode=streetview
center=46.414382,10.013988 to the center of the map
3, navigation of the parameters
The navigation function URL will have three parameters, Saddr,daddr,directionsmode, below is Google's official introduction.
saddr: Sets the starting point for directions searches. This can is a latitude,longitude or a query formatted address. If It is a query string that returns more than one result, the first result would be selected. If The value is a left blank and then the user's current location would be used.
daddr: Sets the end point for directions searches. Has the same format and behavior as saddr .
directionsmode: Method of transportation. Can is set to: driving , transit , bicycling or walking .
Here's an example of how to use
1, the official example, directly into the navigation of two points
Comgooglemaps://? saddr=google+inc,+8th+avenue,+new+york,+ny&daddr=john+f.+kennedy+ International+airport,+van+wyck+expressway,+jamaica,+new+york&directionsmode=transit
2, through the latitude is actually two points of navigation
url = [NSString stringWithFormat:@ "comgooglemaps://?saddr=37.782652,-122.410126&daddr=%lf,%lf &directionsmode=driving", Targetlocation.latitude, Targetlocation.longitude];
3, the location of the mobile phone for the starting point of navigation
url = [NSString stringWithFormat:@ "comgooglemaps://?daddr=%lf,%lf&directionsmode=driving ", Targetlocation.latitude, Targetlocation.longitude];
IOS app via URL to Google Maps navigation