利用手機定位得到座標後,想要知道是位於台灣的哪個地區(ex. 台北市、台南市)
GMSGeocoder *test = [GMSGeocodergeocoder];
[test reverseGeocodeCoordinate:CLLocationCoordinate2DMake(25.058418,121.534354) completionHandler:^(GMSReverseGeocodeResponse *response, NSError *error) {
if (error) {
NSLog(@"error: %@",error);
} else if (response && response.results.count>0){
/*
for (NSInteger i=0; i<response.results.count; i++) {
NSLog(@"%@",[response.results objectAtIndex:i]);
}
*/
GMSAddress *aa = (GMSAddress*)[response.results objectAtIndex:0];
NSLog(@"%@",aa.administrativeArea);
}
else {}
}];
結果:台北市
GoogleMapsAPI記得請更新到1.7以上
GMSAddress
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_address
json輸出
http://blog.csdn.net/meegomeego/article/details/8789081
https://developers.google.com/maps/documentation/geocoding/
留言列表