【发布时间】:2015-09-10 03:15:07
【问题描述】:
我正在尝试提取 CLPlacemark 对象中返回的dependentLocality 信息。数据(匿名)看起来像
{
"cache_control" = CACHEABLE;
"start_index" = 0;
status = "STATUS_SUCCESS";
ttl = 15768000;
type = "COMPONENT_TYPE_ADDRESS";
value = (
{
address = {
"known_accuracy" = POINT;
"localized_address" = (
{
address = {
formattedAddressLine = (
"111 Some St",
"Brooklyn, NY 11111-1111",
"United States"
);
structuredAddress = {
administrativeArea = "New York";
administrativeAreaCode = NY;
areaOfInterest = (
"Long Island"
);
country = "United States";
countryCode = US;
dependentLocality = (
"Bedford Stuyvesant",
Brooklyn
);
fullThoroughfare = "111 Some St";
geoId = (
);
locality = "New York";
postCode = 11206;
postCodeExtension = 1111;
postCodeFull = "11111-1111";
subAdministrativeArea = Kings;
subLocality = Brooklyn;
subThoroughfare = 111;
thoroughfare = "Some St";
};
};
locale = "en_US";
}
);
};
}
);
"values_available" = 1;
version = 7;
"version_domain" = (
apple,
revgeo,
US
);
},
我无法访问内容(除了通过 Apple 的结构化地址属性,它不包含我想要的内容)。例如,我想从上面的内容中提取“Bedford Stuyvesant”,Brooklyn”。已经尝试了多种解决方法,但例如将地标投射到 NSDictionary 失败。任何帮助将不胜感激!
【问题讨论】:
-
我对此进行了进一步研究,无法将 CLPlacemark 对象转换为 NSDictionary(或其他任何东西,显然),因此使用标准 CoreLocation 方法似乎是不可能的。
-
纽约市位置的
subLocality属性未正确分配。看看这个国家的其他一些地方,你会看到社区名称经常出现。例如在旧金山,Nob Hill、Russian Hill、Cow Hollow 都出现在subLocality属性中。我已经能够提取dependentLocality,但它不可靠。
标签: ios swift geocoding cllocationmanager