1

I set up cllocation manage by following code. It work in the open area. However, my phone can't received any datas (all datas was 0) after I went into subway or underground area.

What should I do if I want to make app work in subway as well? Is it necessary to integrate startMonitoringSignificantLocationChanges/startMonitoringForRegion method with standard location update method together? If so, how do I make it?

In init method

locationManager=[[CLLocationManager alloc]init];
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=kCLDistanceFilterNone;
locationManager.delegate=self;
[locationManager startUpdatingLocation];

In cllocation delegate method

 -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    NSLog(@"%@",newLocation);
    NSDate*eventDate=newLocation.timestamp;
    NSTimeInterval howRecent=abs([eventDate timeIntervalSinceNow]);

    if ((newLocation.coordinate.latitude != oldLocation.coordinate.latitude)&&(newLocation.coordinate.longitude != oldLocation.coordinate.longitude)) {
        locationChanged=YES;

    }else{
        locationChanged=NO;
    }

     if ((howRecent <5.0)&&
        ((newLocation.horizontalAccuracy<(oldLocation.horizontalAccuracy -10.0))||
         (newLocation.horizontalAccuracy<50.0)||
         ((newLocation.horizontalAccuracy<=120)&& locationChanged))) {
            self.myLocation=[newLocation copy];

           // NSLog(@"mylocation==%@",[self.myLocation description]);

        }

    //location info draw from plist
    CLLocation *targetLocation = [[CLLocation alloc] initWithLatitude:Target_LAT longitude:Target_LONG];

     double distance = [self.myLocation distanceFromLocation:targetLocation]/1000;
     NSString*distString=[NSString stringWithFormat:@"%0.2f km",distance];

     [delegate getLocationUpdate:self.myLocation distanceUpdate:distString];
       //In this testing app, I use delegate to take cllocation data. Then those datas display in view controller.
}
4

1 回答 1

0

您可以通过多种方式获取移动设备的位置数据。基于设备(GPS、AGPS、WIFI 等,当您在 GPS 视线中时)或基于 CELLID(关闭设备 - 基于手机号码,无论您是否在 GPS 视线中,因为这是基于 cellID)..如您所知如果使用 cellID,应用程序还可以获取地下(视线之外)的位置信息请记住,在地下情况下,如果没有 wifi,那么您就不走运了。我想说您应该使用 geoloqal.com(我)通过 cellID 或 GPS 定位移动设备 - 但是,不幸的是,在地铁中我们仍然无法为您提供帮助。

于 2013-06-22T19:35:56.150 回答