gpt4 book ai didi

ios - 旋转到横向时,Google Maps SDK for iOS 问题

转载 作者:行者123 更新时间:2023-11-29 12:45:17 27 4
gpt4 key购买 nike

我有一个来自适用于 iOS 的 Google Maps SDK(最新版本)的 Google Map。我在 UIScrollerView 中显示这样的 map :

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 进入此 View 时,它会起作用。当您从 Landscape => Landscape 进入此 View 时,它会起作用。

但是当您从肖像 => 肖像然后在 View 中更改为风景时,相机不再居中。另外,当您从 Landscape => Landscape 进入此 View 然后变成 Portrait 时,它会起作用。

知道如何解决肖像 => 风景问题的相机吗?

最佳答案

最后,即使我不明白为什么它不能正确更新,我还是找到了这个解决方案:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (canIshowMap) {
CLLocationCoordinate2D actualLocation = CLLocationCoordinate2DMake([geocodeLatitude floatValue], [geocodeLongitude floatValue]);
GMSCameraUpdate *updatedCamera = [GMSCameraUpdate setTarget:actualLocation];
[mapView_ moveCamera:updatedCamera];
//[mapView_ animateToLocation:actualLocation];
}
}

请注意,注释行并不能修复错误。

关于ios - 旋转到横向时,Google Maps SDK for iOS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23811510/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com