我试图在Google地图上显示多个标记和它们之间的一条线

问题描述:

for (int i=0; i<self.busRoutesArr.count-1; i++) 
{ 
    NSString *lat = [self.latArr objectAtIndex:i]; 
    NSString *lon = [self.longArr objectAtIndex:i] ; 
    double lt=[lat doubleValue]; 
    double ln=[lon doubleValue]; 
    NSLog(@"%f, %f",lt,ln); 

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:lt 
                  longitude:ln 
                   zoom:60]; 


    GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectMake(10, 100, 250, 250) camera:camera]; 

    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.position = camera.target; 
    marker.snippet = @"Hello World"; 
    marker.map = mapView; 
    mapView.translatesAutoresizingMaskIntoConstraints = NO; 
    [self.view addSubview:mapView]; 
} 

只显示1个标记。我想显示所有标记和连接它们的线我试图在Google地图上显示多个标记和它们之间的一条线

+0

看到这个http://*.com/questions/21531974/how-do-i-create-multiple-markers-for-google-maps-in-my-ios-app –

+0

与小型工作更改和循环。我可否知道空闲缩放值以查看所有这些标记。 –

+0

你需要取出for循环'GMSMapView * mapView' –

以下代码用于显示地图中的所有标记。

for(int i=0;i<[array count];i++) {  
     GMSMarker *marker = [[GMSMarker alloc] init]; 
     marker.animated=YES; 
     marker.position = CLLocationCoordinate2DMake(latitude,longitude); 
     marker.title = @"name"; 
     marker.snippet = @"snippet"; 
     marker.map = mapView;  
} 
+0

我得到了一切,除了从数组9点之间画线 –