Xcode google map navigation

前提是你 提交于 2019-12-14 02:40:25

问题


I currently have an application which will drop pins onto various points of interest on a map, all done programmatically on the iPhone.

What I am aiming to get done now is to allow a user to navigate to that location and get turn by turn directions by calling up the built in navigation tools on the iPhone.

Is there anyway that I can do this? I've scoured the developer center and searched both google and here and couldn't find anything about this.


回答1:


You're not allowed to use google directions within your app. The only way you can do this is to send them to the google maps application as per:

- (void)getDirections {
    CLLocationCoordinate2D start = { (startLatitude), (startLongitude) };
    CLLocationCoordinate2D end = { (endLatitude), (endLongitude) };

    NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];

}


来源:https://stackoverflow.com/questions/3979201/xcode-google-map-navigation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!