2014-02-06 40 views
2

我一直在尋找如何使用Google Places API在iOS中繪製兩點之間的路線,但我還沒有找到有趣的地方。您可以在兩點之間繪製路線的唯一方法是調用Web服務並將JSON解析到您的應用中,以在兩點之間路由路線。 Here是一個參考。iOS,如何使用Google Places Api顯示兩點之間的路線?

問題:

是否有任何示例代碼,可以幫助我,我怎麼能兩分,原點(根據用戶當前的位置),與目的地之間繪製路線。

回答

0

你可以得到this教程一個谷歌的開發人員參考。您可以查看this youtube教程以獲取指導。

希望這會有所幫助。歡呼:)

-1
- (void)viewDidLoad { 
    [super viewDidLoad]; 

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:30.692408 
                  longitude:76.767556 
                   zoom:14]; 
    GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView.myLocationEnabled = YES; 

    // Creates markers in the center of the map. 


    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.position = CLLocationCoordinate2DMake(30.6936659, 76.77201819999999); 
    marker.title = @"Chandigarh 47c"; 
    marker.snippet = @"Hello World"; 
    marker.map = mapView; 

    GMSMarker *marker1 = [[GMSMarker alloc] init]; 
    marker1.position = CLLocationCoordinate2DMake(30.742138, 76.818756); 
    marker1.title = @"Sukhna Lake"; 
    marker1.map = mapView; 
    //creating a path 

    GMSMutablePath *path = [GMSMutablePath path]; 
    [path addCoordinate:CLLocationCoordinate2DMake(@(30.6936659).doubleValue,@(76.77201819999999).doubleValue)]; 
    [path addCoordinate:CLLocationCoordinate2DMake(@(30.742138).doubleValue,@(76.818756).doubleValue)]; 

    GMSPolyline *rectangle = [GMSPolyline polylineWithPath:path]; 
    rectangle.strokeWidth = 2.f; 
    rectangle.map = mapView; 
    self.view=mapView; 
} 
+2

這是怎麼回答這個問題? – afxentios

+0

這隻會在兩點之間畫出一條直線。 –

+0

繪製一條直線。 –

相關問題