MKReverseGeocoder 不返回子管理区域

发布于 2024-10-29 13:23:47 字数 272 浏览 2 评论 0原文

我在应用程序中使用 MKReverseGeocoder 来获取用户所在的州(AdministrativeArea)和县(SubAdministrativeArea)。

我刚刚注意到 SubAdministrativeArea 没有返回任何值(null)。状态工作正常。这在过去一直工作正常,但我不确定它何时停止工作。我从模拟器、3GS 和 WiFi iPad 1 中得到了相同的行为。我还收到了来自几百英里外(同一州,不同县)的用户的报告。

还有其他人经历过吗?我还没有发现任何其他类似的错误报告。

I use MKReverseGeocoder in my app to get the state (AdministrativeArea) and county (SubAdministrativeArea) that my user is located in.

I've just noticed that there is no value (null) being returned for SubAdministrativeArea. State is working correctly. This has worked correctly in the past, and I'm not sure exactly when it stopped working. I'm getting the same behavior from the Simulator, 3GS, and WiFi iPad 1. I've also had reports of this from a user who is several hundred miles away (same State, different county).

Has anyone else experienced this? I haven't found any other similar error reports.

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

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

发布评论

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

评论(2

俯瞰星空 2024-11-05 13:23:47

我最近玩过 MKReverseGeocoder,发现它有点不可靠。有时,没有返回街道号码,并且在某些情况下 SubAdministrativeArea 也为空。此外,在某些情况下,地点(城市)值为空。

使用 MKReverseGeocoder 会使您依赖于数据源,这可能不是您所期望的。例如,在纽约玩过它后,我注意到皇后区有时会返回到地区(城市),而布鲁克林则显示为子行政区域(县)。

您可以通过设置 MKMapView 并尝试不同的点,在不同的州轻松测试此行为,或者只是从不同的州/城市/国家获取一组定义的坐标并在测试应用程序上运行它们。

您还可以尝试直接使用 Google Maps Geocoding API,因为它将返回多个结果而不是一个。但是,这可能需要更多工作,因为您需要手动进行解析。以下是示例响应

I have recently played with MKReverseGeocoder and have found it somewhat unreliable. Sometimes, there was no street number returned, and also the SubAdministrativeArea was null in some cases. Also, the Locality (city) value was null in some cases.

Using MKReverseGeocoder makes you dependent on the data source, which might not be what you are expecting. For instance, having played with it in New York, I notice that Queens is sometimes returned in Locality (city), while Brooklyn appears as a SubAdministrativeArea (county).

You could test this behavior easily in different states by setting a MKMapView and try different points, or just get a defined set of coordinates from different states/cities/countries and run them on a test app.

You could also try using the Google Maps Geocoding API directly, as it will return several results instead of one. However, this probably will require more work as you need to do the parsing manually. Here is a sample response.

勿忘初心 2024-11-05 13:23:47

我遇到了完全相同的问题,并求助于使用 addressDictionary 地标属性,例如,

[placemark.addressDictionary objectForKey@"City"]

而不是

placemark.subAdministrativeArea

I ran into the exact same issue and resorted to using the addressDictionary placemark attribute, e.g.,

[placemark.addressDictionary objectForKey@"City"]

instead of

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