Можем ли мы получить текущее местоположение пользователя «Этот синий шар, который анимируется», когда наше устройство отключено. Когда я попытался получить текущее местоположение пользователя и зарегистрировать его, я получаю 0,00000 для обоих долгота и широта здесь - это код, который я использовал для получения текущего местоположения пользователя. Я использую ipad mini для его проверки. Я также добавил CLLocationManagerDelegate в файл .h.Можем ли мы показать местоположение пользователя в автономном режиме в MKMapview
- (void)viewDidLoad {
[self getUserLocation];
self.myMapView.showsUserLocation = YES;
}
-(void)getUserLocation{
if ([CLLocationManager locationServicesEnabled]) {
locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
}else{
NSLog(@"User location Disabled");
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocation *currentGPSLocation = newLocation;
if (currentGPSLocation != nil) {
currentLocation.latitude = self.myMapView.userLocation.coordinate.latitude;
currentLocation.longitude = self.myMapView.userLocation.coordinate.longitude;
currentLocationWalk.latitude=self.myMapView.userLocation.coordinate.latitude;
currentLocationWalk.longitude=self.myMapView.userLocation.coordinate.longitude;
NSLog(@"didUpdateToLocation: %f,%f", self.myMapView.userLocation.coordinate.latitude,self.myMapView.userLocation.coordinate.longitude);
statusLabel.textColor = [UIColor blackColor];
statusLabel.text = [NSString stringWithFormat:@"%f",self.myMapView.userLocation.coordinate.latitude];
statusLabel1.text = [NSString stringWithFormat:@"%f",self.myMapView.userLocation.coordinate.longitude];
}
}
Что значит "в автономном режиме? Нет подключения к интернету вообще (без Wi-Fi и без сотовой связи) или в режиме самолета? – Craig