GPSを使って取得した緯度経度に該当する住所の情報を取得したい場合には、MapKitが提供しているMKReverseGeocorderを使うと便利です。
MKReverseGeocorderを使う時のポイントは、以下の通りです。
- MKReverseGeocoderのインスタンスを作成し、delegateを設定。delegateには、MKReverseGeocoderDelegateプロトコルを実装しているオブジェクトを設定する。
- MKReverseGeocoderのstartを呼び出すことで、プレースマークの取得処理が始まる。(結果は非同期で返される)
- プレースマークが取得できた場合には、MKReverseGeocoderDelegate の reverseGeocoder:didFindPlacemark: が呼び出される。
- プレースマークが取得できなかった場合には、MKReverseGeocoderDelegate の reverseGeocoder:didFailWithError: が呼び出される。
以下に、実装例を示します。
以下は、GPSからの位置情報を取得した後に、MKReverseGeocoderを使ってプレースマークを取得する場合の実装例です。
-- MyViewController.h --
-- MyViewController.m --
I am stricken by the way you embraced this topic. It is not often I come across a website with interesting articles like yours. I will bookmark your feed to keep up to date with your upcoming updates.Just striking and do continue up the good work.
Great topic. I really like following your blog as the articles are so easy to read and follow. You'll have to follow-up with another post.
Thank for good article.
Thank you, I love it. agreed?