如何把谷歌MapView的UIView?
我试图把谷歌地图在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_];
所以,我得到了解决办法。 不pipe怎么说,还是要谢谢你。
最好的祝福。
解:
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_];
基本上在故事板中,对于相应的View(UIVIew),您将显示Google Map,您必须在身份检查器中将该类设置为GMSMapView
。
这是视图控制器在Swift 3中的样子。
class GMapsViewController: UIViewController { @IBOutlet weak var mapContainerView: GMSMapView! override func viewDidLoad() { super.viewDidLoad() let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0) let marker = GMSMarker() marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20) marker.title = "Sydney" marker.map = mapContainerView mapContainerView.moveCamera(GMSCameraUpdate.setCamera(camera)) } }
- 在Xcode中添加其他依赖项后,未find模块“Google地图”
- 我怎样才能添加一个button谷歌地图标记信息窗口上的iOS?
- 如何在谷歌地图iOS Swift中的两个位置之间绘制路线
- search栏点击后消失
- 我可以将iOS的GoogleMaps SDK与-ObjC以外的链接器标志链接起来吗?
- Google地图SDK:在Google地图中以设备在后台移动时绘制正确的折线
- 使用Google-Maps-iOS-SDK(1.8.1)时,架构armv7的未定义符号
- Google地图在iOS中闪烁
- 错误使用未parsing的标识符GMSPlacePickerConfig&GooglePlacePicker? (Google Places 2.0)