如何使用 MKPlacemark 获取门牌号

发布于 2024-12-19 01:58:00 字数 255 浏览 2 评论 0原文

我可以通过将此代码应用于 MKReversegeocoder 来获取街道和城市,

NSString* city = [placemark.addressDictionary valueForKey:@"City"];
NSString* street = [placemark.addressDictionary valueForKey:@"Street"]; 

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

i can get the street and city by applying this code to the MKReversegeocoder

NSString* city = [placemark.addressDictionary valueForKey:@"City"];
NSString* street = [placemark.addressDictionary valueForKey:@"Street"]; 

now i am trying to get the street number is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呆橘 2024-12-26 01:58:01
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
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
远山浅 2024-12-26 01:58:01

我认为您正在寻找的是 MKPlacemarksubThoroughfare 属性。请注意,在 iOS 5.0+ 中,subThoroughfare 未在 MKPlacemark 上声明。它现在从新的超类CLPlacemark 继承了这一点。

I think what you're looking for is the subThoroughfare property of MKPlacemark. Note that in iOS 5.0+, subThoroughfare isn't declared on MKPlacemark. It now inherits this from the new superclass, CLPlacemark.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文