Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 首先检查用户坐标,然后启用功能_Ios_Mapkit_Coordinates - Fatal编程技术网

Ios 首先检查用户坐标,然后启用功能

Ios 首先检查用户坐标,然后启用功能,ios,mapkit,coordinates,Ios,Mapkit,Coordinates,在我的项目中,我需要检查用户坐标。如果用户居住在美国,那么我将启用一个显示空气质量的功能。然后进一步,如果用户住在休斯顿和周围地区,那么我将启用另一个功能,显示另一个功能,臭氧值。我怎样才能做到这一点?我可以用下面的代码检测休斯顿及其周边地区,但我不知道如何将美国各州与休斯顿和世界区分开来 if((currentLocation.latitude>=28.930661 && currentLocation.latitude<=30.443953 &&

在我的项目中,我需要检查用户坐标。如果用户居住在美国,那么我将启用一个显示空气质量的功能。然后进一步,如果用户住在休斯顿和周围地区,那么我将启用另一个功能,显示另一个功能,臭氧值。我怎样才能做到这一点?我可以用下面的代码检测休斯顿及其周边地区,但我不知道如何将美国各州与休斯顿和世界区分开来

if((currentLocation.latitude>=28.930661 && currentLocation.latitude<=30.443953 && currentLocation.longitude>=-95.899668 && currentLocation.longitude<=-94.690486) ||
        currentLocation.longitude == 0 || currentLocation.latitude == 0) {

        // It is in the bounds

        [self.opponentAvatarImageView removeFromSuperview];

        UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:@"Would you like to see ozone cloud in your area or a trace of your walking/driving/biking activity" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"OzoneMap", @"TraceMap", nil];

        [actionsheet showInView:self.view];

    }

if((currentLocation.latitude>=28.930661&¤tLocation.latitude=-95.899668&¤tLocation.longitude使用CLGeocoder类传入您的位置(CLLocation),并让它为您反向地理编码地址。您甚至可以获得城市的具体信息

CLGeocoder *geocoder = [[CLGeocoder alloc] init];

[geocoder reverseGeocodeLocation:location completionHandler:
    ^(NSArray* placemarks, NSError* error){
        CLPlacemark *placemark = [placemarks firstObject];
        if ([placemark.country isEqualToString:@"United States"]) {
             // You're in the U.S.
        }
}];