我正在使用谷歌地图 SDK 来显示我正在开发的 IOS 应用程序上的位置。显示单个位置工作正常,但是当我尝试在单个 map 上显示多个位置时,它会出现白屏。我有一个 restaurantsData 对象,其中包含与一系列餐厅相关的信息(以及每个餐厅的纬度和经度)。现在,当尝试下面的代码时,它会出现白屏。这是我第一次使用 iOS 版 Google map ,请帮助我。
Restaurant *res = [[Restaurant alloc] init];
for (res in _restaurantData) {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: [res.objectLocation.lat doubleValue]
longitude: [res.objectLocation.lng doubleValue] zoom: 5];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
GMSMarker *marker = [ [GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([res.objectLocation.lat doubleValue], [res.objectLocation.lng doubleValue]);
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.icon = [UIImage imageNamed:@"fork_filled"];
marker.map = mapView;
}
最佳答案
你的循环必须是这样的
for (Restaurant *res in _restaurantData) {
GMSMarker *marker = [ [GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([res.objectLocation.lat doubleValue], [res.objectLocation.lng doubleValue]);
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.icon = [UIImage imageNamed:@"fork_filled"];
marker.map = mapView;
}
关于ios - 在谷歌地图上显示多个位置。 IOS/Objective-C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32291197/