2015-02-10 99 views
0

我有20個緯度和20個不同陣列的經度。所以我想用這些點畫出路線。任何人可以建議我如何繪製從A到B的路線& B到C & C到D .....在iOS中的GMSMapView無限位置之間繪製路線

+0

A到B&B到C&C到D .....就像從A到D通過B&C! ? – iOSNoob 2015-02-10 05:30:00

+0

http://www.meonbinary.com/2014/02/route-directions-with-ios7-mapkit-and-google-maps-api看看這個。這可能會幫助你。 – iOSNoob 2015-02-10 05:37:11

+0

他們正在使用蘋果地圖,但我的要求是我想繪製谷歌地圖上的位置(標記和線)。 – user1865963 2015-02-10 06:44:29

回答

0

您可以使用Google Directions API作爲座標對,它將返回可用於創建GMSPath的多段線字符串(使用+ pathFromEncodedPath :),然後您可以使用該路徑在地圖上創建GMSPolyline(使用+ polylineWithPath :)。

0

使用此代碼在標記列表中繪製多段線。 註釋 - 包含GMSMarker對象的NSMutableArray。

- (void)drawLineSubroutine 
     { 
     GMSMutablePath *path = [GMSMutablePath path]; 
    for (int i=0; i<annotations.count; i++) 
    { 
     GMSMarker *marker = [annotations objectAtIndex:i]; 
     [path addCoordinate:CLLocationCoordinate2DMake(marker.position.latitude,marker.position.longitude)]; 

    } 

    polyLine = [GMSPolyline polylineWithPath:path]; 
    polyLine.strokeWidth = 1.0f; 
    polyLine.map = mapGoogle; 

} 
相關問題