如何繪製兩條不與道路連接的目的地之間的自定義路線?在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