gpt4 book ai didi

iphone - 如何在 iPhone 中获取经纬度范围?

转载 作者:行者123 更新时间:2023-11-29 04:03:50 29 4
gpt4 key购买 nike

如何使用两个东北纬度和西南纬度经度坐标在 iPhone 中创建纬度-经度边界,我想检查我当前的纬度经度是否在我的纬度经度边界内。

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

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

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

最佳答案

尝试这样,

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

}
}

关于iphone - 如何在 iPhone 中获取经纬度范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15495670/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com