【发布时间】:2014-10-06 08:05:31
【问题描述】:
我正在努力在 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_];
我已经遍历了我的数组,但我只看到 1 个标记,而我的数组计数为 2 或 3 取决于用户选择的内容。我错过了什么?
【问题讨论】:
-
move camera = ..., mapView_ = ... 从循环中移出。每次创建新的 mapView
标签: ios objective-c google-maps