gpt4 book ai didi

iOS Objective-C 谷歌地图在添加到 subview 时仅在调试时显示

转载 作者:行者123 更新时间:2023-11-29 11:48:41 26 4
gpt4 key购买 nike

我正在使用 google maps SDK,一开始一切正常,但显示为全屏。将 map 添加到 subview 后, map 不再显示。我在 IBAction 上添加了一个断点并注意到在通过之后:

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera];

map 在 subview 中完美显示。

那是我在 IBAction 中的代码:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera];

self.mapView1.myLocationEnabled = YES;
[_mapView1 setMinZoom:12 maxZoom:20];
self.mapView1.mapType = kGMSTypeSatellite;
self.mapView1.settings.compassButton = YES;
_mapView1.delegate = self;
[_mapView1 animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = _mapView1;
[_subview addSubview:_mapView1];

thats how i want it to look like

提前致谢。

最佳答案

试试这个对我有用。

GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];

customView = [GMSMapView mapWithFrame:customView.bounds camera:camera];

customView.myLocationEnabled = YES;
[customView setMinZoom:12 maxZoom:20];
customView.mapType = kGMSTypeSatellite;
customView.delegate = self;
[customView animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = customView;
[self.view addSubview:customView];

GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];
_mapView = [GMSMapView mapWithFrame:customView.bounds camera:camera];

_mapView.myLocationEnabled = YES;
[_mapView setMinZoom:12 maxZoom:20];
_mapView.mapType = kGMSTypeSatellite;
_mapView.settings.compassButton = YES;
_mapView.delegate = self;
[_mapView animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = _mapView;
[customView addSubview:_mapView];
[self.view addSubview:customView];

还要检查你的 _subview 是否隐藏。

关于iOS Objective-C 谷歌地图在添加到 subview 时仅在调试时显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207014/

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