如何从位置坐标获取关于状态的信息?是否有任何第三方框架或API提供从经度值的州/省?如何使用当前位置坐标获取州(国家)信息?
-4
A
回答
1
通过以下方法更新CLLocation值。有迹象表明,你可以从CLPlacemark可以使用placemark.administrativeArea获得
-(void)getLocationDetails:(CLLocation *)location{
CLGeocoder *reverseGeocoder = [[CLGeocoder alloc] init];
[reverseGeocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *myPlacemark = [placemarks objectAtIndex:0];
NSString *countryCode = myPlacemark.ISOcountryCode;
NSString *countryName = myPlacemark.country;
NSString *cityName= myPlacemark.subAdministrativeArea;
NSLog(@"My country code: %@ and countryName: %@ MyCity: %@", countryCode, countryName, cityName);
}];
}
1
国家获取各种信息。
CLLocation *loc = [[CLLocation alloc]initWithLatitude:coordinate.latitude longitude:coordinate.longitude
];
[ceo reverseGeocodeLocation:loc
completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"placemark %@",placemark);
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"addressDictionary %@", placemark.addressDictionary);
NSLog(@"placemark %@",placemark.region);
NSLog(@"placemark %@",placemark.country); // Give Country Name
NSLog(@"placemark %@",placemark.locality); // Extract the city name
NSLog(@"location %@",placemark.name);
NSLog(@"location %@",placemark.ocean);
NSLog(@"location %@",placemark.postalCode);
NSLog(@"location %@",placemark.subLocality);
NSLog(@"location %@",placemark.location);
//Print the location to console
NSLog(@"I am currently at %@",locatedAt);
NSLog(@"state name %@",placemark.administrativeArea);
_City.text=[placemark.addressDictionary objectForKey:@"City"];
[locationManager stopUpdatingLocation];
}
];
}
1
您可以使用反向地理代码获取它。看下面的例子:
geocoder = [[CLGeocoder alloc] init];
//newlocation is CLLocation object you need to pass user location there.
[geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil && [placemarks count] > 0) {
placemark = [placemarks lastObject];
// placemark.administrativeArea is state of use
} else {
NSLog(@"%@", error.debugDescription);
}
}];
从CLPlacemark.h://地标字典包含用户的其他信息将如下所示。
@property (nonatomic, readonly) NSString *name; // eg. Apple Inc.
@property (nonatomic, readonly) NSString *thoroughfare; // street address, eg. 1 Infinite Loop
@property (nonatomic, readonly) NSString *subThoroughfare; // eg. 1
@property (nonatomic, readonly) NSString *locality; // city, eg. Cupertino
@property (nonatomic, readonly) NSString *subLocality; // neighborhood, common name, eg. Mission District
@property (nonatomic, readonly) NSString *administrativeArea; // state, eg. CA
@property (nonatomic, readonly) NSString *subAdministrativeArea; // county, eg. Santa Clara
@property (nonatomic, readonly) NSString *postalCode; // zip code, eg. 95014
@property (nonatomic, readonly) NSString *ISOcountryCode; // eg. US
@property (nonatomic, readonly) NSString *country; // eg. United States
@property (nonatomic, readonly) NSString *inlandWater; // eg. Lake Tahoe
@property (nonatomic, readonly) NSString *ocean; // eg. Pacific Ocean
@property (nonatomic, readonly) NSArray *areasOfInterest; // eg. Golden Gate Park
相关问题
- 1. 如何获取用户位置国家
- 2. 如何从iPhone的核心位置获取当前(美国)国家?
- 3. 使用Place picker google API获取当前位置坐标android
- 4. 如何获取Core Location的当前位置或GPS坐标?
- 5. 如何在google map v2中获取当前位置信息?
- 6. 如何从当前位置获取数据库中的信息?
- 7. 如何获取用户当前国家电话区号前:+966
- 8. 为国家获取重复的州名
- 9. 获取州/省和国家的时区?
- 10. 通过CloudMade获取美国州的几何坐标
- 11. iOS:如何使用GPRS获取当前位置信息而非GPS?
- 12. 如何获取用户的国家信息
- 13. 获取当前国家/地区名称
- 14. 错误获取当前的国家
- 15. 获取当前坐标
- 16. 从坐标获取国家名称(使用CLLocationManager)
- 17. 使用位置的当前国家的紧急电话号码
- 18. Android - 如何根据需求获取当前用户坐标/位置?
- 19. Android获取国家代码的位置
- 20. android代码获取当前位置坐标到一个按钮
- 21. 在android中获取当前位置(坐标)?
- 22. 国家,州,省WebService?
- 23. 使用经典ASP 3.0获取访问者国家信息
- 24. 如何获取用户当前位置
- 25. 从坐标获取位置?
- 26. 如何获取Android中的国家/地区信息?
- 27. 如何从reverseGeocodeCoordinate获取国家,州,城市?
- 28. 获取当前位置的提供者详细信息在iPhone
- 29. 如何使用坐标获取当前区域名称?
- 30. 如何在iphone中获取当前位置在地图上的坐标值?
它显示码字和码字也是错误.... – sp309
当我试图CLLocation *位置= [[CLLocation的alloc] initWithLatitude:19.0760经度:72.8777];它给我*我的国家代码:IN和国家/地区名称:印度MyCity:孟买* – kb920
给我你正在尝试的纬度经度值。 – kb920