我正在尝试使用Google Map SDK for IOS在子视图中实现我的当前位置。我正在尝试将GMSMapView实现为一个IBOutlet。
我的头文件有代码
#import <UIKit/UIKit.h>
#import <Google-Maps-iOS-SDK/GoogleMaps/GoogleMaps.h>
@interface TripLandingViewController : UIViewController
@property IBOutlet GMSMapView *mapView;
@end我的.m文件有代码
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Tile.png"]];
self.mapView.myLocationEnabled = TRUE;
NSLog(@"\n\n\n My Location is %f,%f \n\n\n",self.mapView.myLocation.coordinate.latitude,self.mapView.myLocation.coordinate.longitude);
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:self.mapView.myLocation.coordinate.latitude
longitude:self.mapView.myLocation.coordinate.longitude
zoom:10];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];不管,我为摄像机中的坐标提供了什么硬编码值作为参数。我得到了错误的地点(这里,英国),这是完全没有更新。
但是当我试着
self.View = [GMSMapView mapWithFrame:CGRectZero camera:camera];我能够加载正确的地图视图在主视图与正确的位置坐标。
我尝试了通过堆栈溢出将Google添加到SubViews的所有答案。
Cannot put a google maps GMSMapView in a subview of main main view?
How to set the frame for mapview - in google GMSMap for iOS6
How put Google MapView in UIView?
Google Maps iOS SDK, Getting Current Location of user
但似乎什么都起不到作用。请帮助,因为我是新的IOS编程。
发布于 2014-05-25 21:33:22
使用:
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:0 longitude:0 zoom:15];
self.mapView.camera = camera;而不是使用:
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];我不完全确定为什么,但是当您的GMSMapView是UIViewController的子视图时,这个方法可以工作。
https://stackoverflow.com/questions/22189096
复制相似问题