IOS app via URL to Google Maps navigation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.