目前的城市是零;

时间:2012-04-12 20:28:30

标签: iphone objective-c ios geolocation

我正在尝试使用反向geocodder来获取当前的城市,州和国家,这是一个奇怪的问题。州和国家都很好,但城市是“零”。任何人都可以帮帮我。

我正在使用以下代码:

- (void)reverseGeocoder:(MKReverseGeocoder*)geocoder didFindPlacemark:(MKPlacemark*)place
{
    NSDictionary *addressDict = place.addressDictionary;
    self.currentCity = [addressDict objectForKey:(NSString*)kABPersonAddressCityKey];
    self.currentState = [addressDict objectForKey:(NSString*)kABPersonAddressStateKey];
    self.currentCountry = place.country;
    self.currentCountryCode = place.countryCode;
}

1 个答案:

答案 0 :(得分:2)

它使用谷歌地图,所以到这里看看如何直接检查

https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

使用您所在位置的纬度/经度检查:

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

你有一个城市吗?如果是这样,我建议您尝试捕获应用程序和反向地理编码服务器之间的网络流量。一种简单的方法是安装Wireshark,然后使用模拟器和自定义位置(在最新的模拟器中支持)。