【发布时间】:2014-10-19 00:10:24
【问题描述】:
我正在尝试在我的应用中实现当前位置。请在下面查看我的viewDidLoad 代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self hideTabBar:self.tabBarController];
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.settings.compassButton = YES;
mapView_.settings.myLocationButton = YES;
mapView_.accessibilityElementsHidden = NO;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
}
我可以在 iOS 模拟器 (iPhone 4s) 中看到标记设置为悉尼的地图,但在任何地方都看不到蓝点。当前位置是否有效但 UI 元素被隐藏?
感谢您的任何帮助/建议!
【问题讨论】:
-
您需要请求获得用户位置的权限才能在 MapView 上显示它。
-
抱歉,我是 iOS 新手。我如何请求许可?这是模拟器设置还是以编程方式完成?
-
查看CLLocation类参考
标签: ios objective-c iphone google-maps xcode6