如何绘制两条不与道路连接的目的地之间的自定义路线?在iOS的Google地图中绘制自定义路线
例如,如果来源是薄饼厂和目标是ATI的解决方案我不得不得出这样的路线,但没有道路连接这两个地方。
我想谷歌的折线代码,但它提供了唯一的道路航点。
NSString *urlString = [NSString stringWithFormat:@"%@?origin=%@,%@&destination=%f,%f&sensor=false&waypoints=optimize:true&mode=driving", @"https://maps.googleapis.com/maps/api/directions/json", getmycurrlat, getmycurrlong, LATI, LONGI];
NSLog(@"my driving api URL --- %@", urlString);
NSLog(@"you clicked on button %ld", (long)sender.tag);
NSURL* url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@", urlString]];
NSURLResponse* res;
NSError* err;
NSData* data = [NSURLConnection sendSynchronousRequest:[[NSURLRequest alloc] initWithURL:url] returningResponse:&res error:&err];
if (data == nil) {
return;
}
NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary* routes = [dic objectForKey:@"routes"][0];
NSDictionary* route = [routes objectForKey:@"overview_polyline"];
NSString* overview_route = [route objectForKey:@"points"];
GMSPath* path = [GMSPath pathFromEncodedPath:overview_route];
GMSPolyline* polyline = [GMSPolyline polylineWithPath:path];
polyline.strokeWidth = 5.f;
polyline.map = self.mapView;
所有帮助表示感谢!
地图制作击溃首选的标准方法是在适当的空间道路绕道走,什么样定制你想制作的路线? – vaibhav
比萨工厂和ATI解决方案之间没有连接的道路,只有两栋建筑之间有空间。是否有任何可能的方式来绘制快照中的东西?我的exp地图中的 –
只会在连接的道路上创建路线,如果您事先提供了静态的'lat'' long',但也有动态的方式可以在移动[看一看](http:// stackoverflow。 )的COM /问题/ 18422826 /使用-谷歌-地图如何到磁道-A-用户 - 地点 - 和 - 显示最路径行进-。 – vaibhav