gpt4 book ai didi

ios - 如何将 Google MapView 放入 UIView 中?

转载 作者:可可西里 更新时间:2023-11-01 03:06:13 24 4
gpt4 key购买 nike

我试图将 Google MapView 放入 UIView 但我没有显示任何内容。

我的代码,

*.h

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnLocate;
@property (weak, nonatomic) IBOutlet GMSMapView *mapView_;
@property (weak, nonatomic) IBOutlet UIView *mapView;

@end

*.m

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
self.mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.mapView_.myLocationEnabled = YES;
self.mapView = self.mapView_;

谢谢。

解决方案

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];

// Indicating the map frame bounds
self.mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds camera: camera];
self.mapView_.myLocationEnabled = YES;

// Add as subview the mapview
[self.mapView addSubview: self.mapView_];

所以,我得到了解决方案。无论如何谢谢。

最好的问候。

最佳答案

解决方法:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];

// Indicating the map frame bounds
self.mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds camera: camera];
self.mapView_.myLocationEnabled = YES;

// Add as subview the mapview
[self.mapView addSubview: self.mapView_];

关于ios - 如何将 Google MapView 放入 UIView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19177897/

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