我試圖在我的應用程序中實現當前位置。請參閱我的代碼如下viewDidLoad
:當前位置的藍點不顯示使用谷歌地圖的iOS
- (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_;
}
我可以看到在iPhone模擬器(iPhone 4S)設置爲悉尼標記的地圖,但在任何地方看到任何藍色的圓點。當前位置可能正在工作,但UI元素已隱藏?
感謝您的任何幫助/建議!
您需要獲得獲取用戶位置的權限,甚至可以在MapView上顯示它。 – Lefteris 2014-10-19 00:28:59
對不起,我對iOS很新。我如何申請許可?這是模擬器設置還是以編程方式完成? – BlueBucket7 2014-10-19 00:34:20
看看CLLocation類的參考 – Lefteris 2014-10-19 00:37:59