因爲我已經用我的位置按鈕,此方法...mylocationButton不更新我的位置爲什麼?
[mapView.settings setMyLocationButton:YES];
//AddObserverForDriverCurrentLocation
[mapView addObserver:self forKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew context:NULL];
[self.view addSubview:mapView];
dispatch_async(dispatch_get_main_queue(), ^{
mapView.myLocationEnabled = YES;
});
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:
(NSArray<CLLocation *> *)locations
{
NSLog(@"Locations:%@",[locations lastObject]);
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"myLocation"]) {
CLLocation *location = [object myLocation];
NSLog(@"Location, %@,", location);
CLLocationCoordinate2D target =
CLLocationCoordinate2DMake(22.7,75.8);
[mapView animateToLocation:target];
[mapView animateToZoom:17];
}
}
但是,當我在myLocation按鈕點擊它是不是uspdating我的位置,請幫助
面臨什麼問題.... –
我mylocation按鈕沒有更新我的當前location.When我移動地圖和點擊mylocation按鈕它不拽我回到我的當前位置在地圖上。 –
把斷點,並檢查一次的方法被調用或不 –