Ste*_*hot 1 google-maps objective-c ios
我正在努力在iOS 8.0的Google地图中获取多个标记。我当前的代码是:
ResourceGroep *rsg = [ResourceGroep alloc]init;
GMSCameraPosition *camera = nil;
for (int i = 0; i < [rsg.chosenResourceArray count]; i++)
{
camera = [GMSCameraPosition cameraWithLatitude:[loc.Latitude doubleValue]
longitude:[loc.Long doubleValue]
zoom:15];
mapView_ = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
mapView_.myLocationEnabled = NO;
CLLocationCoordinate2D position = { [rsg.Latitude doubleValue], [rsg.Long doubleValue] };
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = [NSString stringWithFormat:@"Marker %i", i];
marker.appearAnimation = YES;
marker.flat = YES;
marker.snippet = @"";
marker.map = mapView_;
}
[self.view addSubview:mapView_];
Run Code Online (Sandbox Code Playgroud)
我已经遍历了数组,但是我只能看到1个标记,而数组计数大约是2还是3取决于用户选择的对象。我想念什么?
检查一下:
ResourceGroep *rsg = [ResourceGroep alloc]init;
GMSCameraPosition *camera = nil;
camera = [GMSCameraPosition cameraWithLatitude:[loc.Latitude doubleValue]
longitude:[loc.Long doubleValue]
zoom:15];
mapView_ = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
mapView_.myLocationEnabled = NO;
for(int i = 0; i < [rsg.chosenResourceArray count]; i++)
{
CLLocationCoordinate2D position = { [rsg.Latitude doubleValue], [rsg.Long doubleValue] };
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = [NSString stringWithFormat:@"Marker %i", i];
marker.appearAnimation = YES;
marker.flat = YES;
marker.snippet = @"";
marker.map = mapView_;
}
[self.view addSubview:mapView_];
Run Code Online (Sandbox Code Playgroud)
我刚刚更改了一些代码的位置。