如何使用两个NE和SW纬度经度坐标在iPhone中创建纬度 - 经度界限,我想检查当前纬度经度是否在我的纬度经度范围内。
我使用以下纬度经度坐标创建了一个边界:
double minLng = 7.880571
double maxLng = 8.357336
double minLat = 49.108775
double maxLat = 49.288638
我想检查我的其他纬度经度是否在此范围内。
答案 0 :(得分: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
}
}
答案 1 :(得分:0)
如果按当前表示设备的当前位置,则需要查看CLLocationManager类及其委托方法,即location
属性,其中包含有关当前纬度和经度的信息。其余的很简单。