2012-01-09 47 views

回答

2

試用本教程link,它只顯示兩點之間的單一路線。您需要根據您的要求進行更改。距離10公里。你必須使用兩點(緯度,經度)來計算距離。

3

我認爲這可能對你有所幫助,因爲我已經完成了城市之間的繪製路線。

CLLocationCoordinate2D firstCoords; 
    firstCoords.latitude = lat1; 
    firstCoords.longitude = lng1; 

CLLocationCoordinate2D secondCoords; 
    secondCoords.latitude=lat2; 
    secondCoords.longitude=lng2; 

NSLog(@" %f", lat1); 
NSLog(@" %f", lng1); 
NSLog(@" %f", lat2); 
NSLog(@" %f", lng2);  
routeCoordinates[0] = CLLocationCoordinate2DMake(lat1, lng1); 
routeCoordinates[1] = CLLocationCoordinate2DMake(lat2, lng2); 
MKPolyline *routeLine = [MKPolyline polylineWithCoordinates:routeCoordinates count:2]; 
[mapView addOverlay:routeLine]; 
+0

routeCoordinates?它是什麼? – 2013-03-17 18:13:57