【发布时间】:2014-05-23 03:45:30
【问题描述】:
我有一个来自 Google Maps SDK for iOS(最新版本)的 Google Map。我在UIScrollerView 中显示这样的地图:
showMarker = YES;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:[geocodeLatitude floatValue] longitude:[geocodeLongitude floatValue] zoom:13];
[self setupMapWithCamera:camera withLatitude:geocodeLatitude withLongitude:geocodeLongitude];
float mapHeight = 50;
[mapView_ setFrame:CGRectMake(0, 0, widthOfBlock, mapHeight)];
[self.scroller addSubview:mapView_];
调用的方法是:
-(void)setupMapWithCamera:(GMSCameraPosition *)camera withLatitude:(NSString *)Slatitude withLongitude:(NSString *)Slongitude {
// setup map
[mapView_ clear];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.settings.scrollGestures = NO;
mapView_.settings.zoomGestures = NO;
// setup marker
if (geocodesuccess || showMarker) {
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([Slatitude floatValue], [Slongitude floatValue]);
if ([ShopWithDatas.open isEqualToString:@"1"] || [ShopWithDatas.open2424 isEqualToString:@"1"]) {
marker.icon = [GMSMarker markerImageWithColor:[UIColor greenColor]];
} else {
marker.icon = [GMSMarker markerImageWithColor:[UIColor redColor]];
}
[mapView_ setSelectedMarker:marker];
marker.map = mapView_;
}
}
因此,当您从 Portrait => Portrait 进入此视图时,它会起作用。 当您从 Landscape => Landscape 进入此视图时,它会起作用。
但是当您从人像 => 人像然后在视图中更改为风景时,相机不再居中。另外,当您从 Landscape => Landscape 进入此视图然后变成 Portrait 时,它可以工作。
知道如何修复肖像 => 风景问题的相机吗?
【问题讨论】:
标签: ios objective-c google-maps google-maps-sdk-ios