我试图将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_]; 所以我找到解决办法了。不管怎样,谢谢你。
诚挚的问候。
发布于 2013-10-04 14:30:02
解决方案:
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_]; 发布于 2017-07-16 20:09:09
本质上,在故事板中,对于相应的视图(UIVIew),您要显示Google,您必须在身份检查器中将类设置为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))
}
}https://stackoverflow.com/questions/19177897
复制相似问题