0

如何使用两个 NE 和 SW 纬度经度坐标在 iPhone 中创建经纬度界限,我想检查我当前的纬度经度是否在我的纬度经度界限内。

我使用以下纬度经度坐标创建了一个界限:

double minLng = 7.880571
double maxLng = 8.357336
double minLat = 49.108775
double maxLat = 49.288638

我想检查我的其他纬度经度是否在此范围内。

4

2 回答 2

1

像这样试试

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

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    if(newLocation.coordinate.latitude>=49.108775 && newLocation.coordinate.latitude<=49.288638 && newLocation.coordinate.longitude>=7.880571 && newLocation.coordinate.longitude<=8.357336 ) {

         // It is in the bounds

    }
}
于 2013-03-19T09:55:01.603 回答
0

如果当前是指设备的当前位置,则需要查看CLLocationManager类及其委托方法,即location包含有关当前纬度和经度信息的属性。其余的非常简单。

于 2013-03-19T09:37:01.570 回答