gpt4 book ai didi

iphone - 如何使用 MKPlacemark 获取门牌号

转载 作者:行者123 更新时间:2023-12-01 15:54:28 24 4
gpt4 key购买 nike

我可以通过将此代码应用于 MKReversegeocoder

来获取街道和城市
NSString* city = [placemark.addressDictionary valueForKey:@"City"];
NSString* street = [placemark.addressDictionary valueForKey:@"Street"];

现在我正在尝试获取街道号码,这可能吗?

最佳答案

self.userCoord = [[CLLocation alloc] initWithLatitude:geoPoint.latitude longitude:geoPoint.longitude];

CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:self.userCoord completionHandler:^(NSArray *placemarks, NSError *error)
{
if (error == nil && [placemarks count] > 0)
{
CLPlacemark *placemark = [placemarks lastObject];
self.city.text = placemark.locality;
self.street.text = placemark.thoroughfare;
self.house.text = place mark.subThoroughfare;
}
}
// address dictionary properties
@property (nonatomic, readonly, copy) NSString *name; // eg. Apple Inc.
@property (nonatomic, readonly, copy) NSString *thoroughfare; // street address, eg. 1 Infinite Loop
@property (nonatomic, readonly, copy) NSString *subThoroughfare; // eg. 1
@property (nonatomic, readonly, copy) NSString *locality; // city, eg. Cupertino
@property (nonatomic, readonly, copy) NSString *subLocality; // neighborhood, common name, eg. Mission District
@property (nonatomic, readonly, copy) NSString *administrativeArea; // state, eg. CA
@property (nonatomic, readonly, copy) NSString *subAdministrativeArea; // county, eg. Santa Clara
@property (nonatomic, readonly, copy) NSString *postalCode; // zip code, eg. 95014
@property (nonatomic, readonly, copy) NSString *ISOcountryCode; // eg. US
@property (nonatomic, readonly, copy) NSString *country; // eg. United States
@property (nonatomic, readonly, copy) NSString *inlandWater; // eg. Lake Tahoe
@property (nonatomic, readonly, copy) NSString *ocean; // eg. Pacific Ocean
@property (nonatomic, readonly, copy) NSArray *areasOfInterest; // eg. Golden Gate Park

关于iphone - 如何使用 MKPlacemark 获取门牌号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8334621/

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