MKReverseGeocoderã§ãã精度ã®é«ãä½ææ å ±ã¯MKPlacemark.addressDictionaryã«ãã£ã!
å
æ¥MKReverseGeocoderã®ç²¾åº¦ã¯æ±ºãã¦é«ããªãããã ã¨æ¸ããã、ããã¯ééãã ã£ã。
ç´ç·æ¢æ»: iPhoneã¢ããªã§ã®ããé«ç²¾åº¦ãªéã¸ãªã³ã¼ãã£ã³ã°ãæ±ãã¦・・・
ãã精度ã®é«ãä½ææ å ±ã¯、MKPlacemark.addressDictionary.FormattedAddressLinesããåå¾ã§ããã¨ããã£ã。
æ¥æ¬ä¸ã®è²ã ãªå ´æãåºåããã¦ã¿ãã、å½å ã®å ´åã¯MKPlacemarkã®æ å ±ã¨FormattedAddressLinesã®æ å ±ã¯éãã¯ãããã®ã®、大ä½ä¼¼ããããªæååã使ããã¦ããã®ã§、ãã£ã«ã¿ãªã³ã°ããã°MKPlacemarkã®ããããã£ã¼ã§è¶³ãã¦ããªãé¨åãå¤æãã¦åå¾ãããã¨ãã§ããã ãã。
æµ·å¤ãåºåããã¦ã¿ãã¨ãã、ããããæ å ±ããªãã£ããå¿ ãããMKPlacemarkã®ããããã£ã¼ã¨å¯¾å¿ãã¦ããªãã£ãã・・・ã¨ç¸å½è¦å´ãããã 。
ç´ç·æ¢æ»: iPhoneã¢ããªã§ã®ããé«ç²¾åº¦ãªéã¸ãªã³ã¼ãã£ã³ã°ãæ±ãã¦・・・
ãã精度ã®é«ãä½ææ å ±ã¯、MKPlacemark.addressDictionary.FormattedAddressLinesããåå¾ã§ããã¨ããã£ã。
/** * * MKPlacemark.addressDictionaryããåå¾ããFormattedAddressLinesã * ä¸è¡ã®æååã¨ãã¦è¿ã * */ - (NSString *)getFormattedAddressLineFromPlacemark:(MKPlacemark *)pm { //æçµçãªä½ææåå NSString *line = @""; //ã¾ãã¯MKPlacemarkã®ããããã£ã¼ãåºå NSLog(@"MKPlacemarkåºå thoroughfare=%@ subThoroughfare=%@ locality=%@ subLocality=%@ administrativeArea=%@ subAdministrativeArea=%@ postalCode=%@ country=%@ countryCode=%@", pm.thoroughfare, pm.subThoroughfare, pm.locality, pm.subLocality, pm.administrativeArea, pm.subAdministrativeArea, pm.postalCode, pm.country, pm.countryCode); //ãã詳細ãªä½æã¯MKPlacemark.addressDictionaryã«é ããã¦ãã NSDictionary *dict = pm.addressDictionary; //for (id key in dict) { // NSLog(@"key=%@ value=%@", key, [dict objectForKey:key]); //} //FormattedAddressLinesãä¸è¡ã®æååã«é£çµ //ããã¥ã¡ã³ãã«ã¯æè¨ããã¦ããã¨ãããè¦å½ãããªããFormattedAddressLinesã¯é åã§è¿ã£ã¦æ¥ãããã NSArray *lines = [dict valueForKey:@"FormattedAddressLines"]; for (int i = 0; i < lines.count; i++) { line = [line stringByAppendingFormat:@"%@ ", [lines objectAtIndex:i]]; } //ä¸ã§åºåããããããã£ã¼ã¨æ¯è¼ãã¦、ãã¡ãã«ã ãåå¨ããæ å ±ãããã¨ããã //(éµä¾¿çªå·ãä½æã®æ«å°¾「-3」) NSLog(@"%@:FormattedAddressLinesåºå lines.count=%d", line, lines.count); return line; }ä¾ãã°、ä½ç½®ãå½ä¼è°äºå ã¨ãã¦éã¸ãªã³ã¼ãã£ã³ã°ãè¡ã、ãã®çµæã®MKPlacemarkããã®ã¡ã½ããã使ã£ã¦åºåããã¨ãããªã。
MKPlacemarkã®ããããã£ã¼ã®åºåãFormattedAddressLinesåºåã«ã§ããã ãä¼¼ãã¦æ¸ãã¨ãããªã。MKPlacemarkåºå thoroughfare=ï¼ä¸ç® subThoroughfare=ï¼ locality=å代ç°åº subLocality=æ°¸ç°çº administrativeArea=æ±äº¬é½ subAdministrativeArea=(null) postalCode=(null) country=æ¥æ¬ countryCode=JP æ¥æ¬ 〒100-0014 æ±äº¬é½å代ç°åºæ°¸ç°çºï¼ä¸ç®ï¼−ï¼ :FormattedAddressLinesåºå lines.count=2
æ¥æ¬ æ±äº¬é½å代ç°åºæ°¸ç°çºï¼ä¸ç®ï¼ã¤ã¾ã、FormattedAddressLinesåºåã«æ¯ã¹ã¦éµä¾¿çªå·「〒100-0014」ã¨çªå°ã¬ãã«ã®「−ï¼」ã®é¨åã®æ å ±ãæãè½ã¡ã¦ãããã¨ãããã。 ä¸ã®ã³ã¼ãã§ã¯ã³ã¡ã³ãããã¦ããã、addressDictionaryã®ä¸èº«ãåºåãã¦ã¿ãã¨ãããªã。
ã©ãããMKPlacemarkã®ããããã£ã¼ã¯addressDictionaryã®ä¸èº«ãé©å½ã«å±éãããã®ãå ¥ã£ã¦ããããã 。key=Street value=ï¼ä¸ç® ï¼ key=State value=æ±äº¬é½ key=CountryCode value=JP key=FormattedAddressLines value=( "¥U65e5¥U672c", "¥U3012100-0014 ¥U6771¥U4eac¥U90fd¥U5343¥U4ee3¥U7530¥U533a¥U6c38¥U7530¥U753¥Uff11¥U4e01¥U76ee¥Uff17¥U2212¥Uff11" ) key=City value=å代ç°åº key=SubThoroughfare value=ï¼ key=Country value=æ¥æ¬ key=Thoroughfare value=ï¼ä¸ç® key=SubLocality value=æ°¸ç°çº
æ¥æ¬ä¸ã®è²ã ãªå ´æãåºåããã¦ã¿ãã、å½å ã®å ´åã¯MKPlacemarkã®æ å ±ã¨FormattedAddressLinesã®æ å ±ã¯éãã¯ãããã®ã®、大ä½ä¼¼ããããªæååã使ããã¦ããã®ã§、ãã£ã«ã¿ãªã³ã°ããã°MKPlacemarkã®ããããã£ã¼ã§è¶³ãã¦ããªãé¨åãå¤æãã¦åå¾ãããã¨ãã§ããã ãã。
æµ·å¤ãåºåããã¦ã¿ãã¨ãã、ããããæ å ±ããªãã£ããå¿ ãããMKPlacemarkã®ããããã£ã¼ã¨å¯¾å¿ãã¦ããªãã£ãã・・・ã¨ç¸å½è¦å´ãããã 。
ãããªãã ã¼(^^;)
è¿ä¿¡åé¤æ·±ãã¨ããã«å ¥ã£ã¦ãããã ãã。