我有来自Google Maps SDK for iOS的谷歌地图(最新版本)。我在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 =>输入此视图时,它会起作用肖像。 从Landscape =>进入此视图时,它可以正常工作横向。
但是当你从Portrait =>出发时相机不再居中纵向然后在视图中更改为横向。另外,当您从Landscape =>输入此视图时,它可以正常工作风景然后变成肖像。
任何想法如何修复相机的肖像=>景观问题?
答案 0 :(得分:1)
最后,即使我不明白为什么它没有正确更新,我找到了这个解决方案:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (canIshowMap) {
CLLocationCoordinate2D actualLocation = CLLocationCoordinate2DMake([geocodeLatitude floatValue], [geocodeLongitude floatValue]);
GMSCameraUpdate *updatedCamera = [GMSCameraUpdate setTarget:actualLocation];
[mapView_ moveCamera:updatedCamera];
//[mapView_ animateToLocation:actualLocation];
}
}
请注意,注释行不能修复错误。