私は、地上にいるときにうまく機能する大量輸送アプリのユーザーの場所を取得するアプリを作成しようとしています。地下にいると、Wi-Fi や携帯電話の信号がある場合でも、場所が更新されません。以下は私が使用しているコードです。私が理解したことから、iPhone は Wi-Fi 信号からのみ位置情報を取得できますが、これは正しくありませんか? どんな助けでも大歓迎です、事前に感謝します!
- (void)viewDidLoad
{
[super viewDidLoad];
//********************** Add map ******************************************
//setup location manager
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
//setup map view
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 160.0f)];
mapView.showsUserLocation = YES;
mapView.userTrackingMode = MKUserTrackingModeFollow;
//run loop in background
loopTimer = [[NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(tick:) userInfo:nil repeats:YES]retain];
}
// Search for n seconds to get the best location during that time
- (void) tick: (NSTimer *) timer
{
// Check for valid coordinate
CLLocationCoordinate2D coord = mapView.userLocation.location.coordinate;
if (!coord.latitude && !coord.longitude) return;
//get coordinates to update map
[mapView setRegion:MKCoordinateRegionMake(coord, MKCoordinateSpanMake(0.005f, 0.005f)) animated:NO];
//update current location in view
currentLatView.text = [NSString stringWithFormat:@"%.2f", coord.latitude];
currentLonView.text = [NSString stringWithFormat:@"%.1f", coord.longitude];
}