iOSのMapkitのデフォルトのロケーションポイントからロケーションの名前を取得するにはどうすればよいですか?私はそれ(ex.Swissホテル)をクリックすると、スウィフトに名を取得したいデフォルトアノテーションからロケーション名を取得する方法iOSのMapkit
1
A
答えて
3
ステップ-1
マップ上のジェスチャーを追加
let tgr = UITapGestureRecognizer(target: self, action: #selector(self.tapGestureHandler))
tgr.delegate = self
mapView.addGestureRecognizer(tgr)
ステップ-2
func tapGestureHandler(tgr: UITapGestureRecognizer)
{
let touchPoint = tgr.locationInView(yourmapview)
let touchMapCoordinate = yourmapview.convertPoint(touchPoint, toCoordinateFromView: yourmapview)
print("tapGestureHandler: touchMapCoordinate = \(touchMapCoordinate.latitude),\(touchMapCoordinate.longitude)")
}
ステップ-3
ついに
let geoCoder = CLGeocoder()
let location = CLLocation(latitude: touchMapCoordinate.latitude, longitude: touchMapCoordinate.longitude)
geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in
// Place details
var placeMark: CLPlacemark!
placeMark = placemarks?[0]
// Address dictionary
print(placeMark.addressDictionary)
// Location name
if let locationName = placeMark.addressDictionary!["Name"] as? NSString {
print(locationName)
}
// Street address
if let street = placeMark.addressDictionary!["Thoroughfare"] as? NSString {
print(street)
}
// City
if let city = placeMark.addressDictionary!["City"] as? NSString {
print(city)
}
// Zip code
if let zip = placeMark.addressDictionary!["ZIP"] as? NSString {
print(zip)
}
// Country
if let country = placeMark.addressDictionary!["Country"] as? NSString {
print(country)
}
})
関連する問題
- 1. MS AccessからのJSP結果セット - ロケーション名の取得方法?
- 2. ロケーションの取得方法 -
- 3. Mapkit didSelectAnnotationView:カスタムプロパティを取得する方法
- 4. iOS 7のロケーションをリクエストする方法
- 5. iOS 5でのロケーションの取得
- 6. フェッチされた座標からロケーション名を取得
- 7. Googleマップから選択したロケーション名を取得
- 8. ios mapkit、キャリア名が[LogMessageLogging]でクラッシュする6.1 CarrierNameを取得できません
- 9. onLocationChanged(Location location)メソッドでロケーション名を取得
- 10. ロケーションの設定にリダイレクトした後にロケーションを取得する方法
- 11. ロケーションを取得するベストプラクティス
- 12. Eclipse WorkspaceのロケーションURIを取得する方法
- 13. iOS逆ジオコーディング(アドレスだけでなく、座標からロケーションのNAMEを取得)
- 14. Swift 2 Mapkitユーザーの場所からシティを取得する
- 15. iphoneでmapkitを使って地名を取得するには?
- 16. ロケーション(アフィニティゾーン)またはネームクラスター(ファブリックサービス)を取得する方法
- 17. ファイル名から画像の寸法を取得する方法
- 18. iosのuiwebviewからイメージを取得する方法
- 19. ios 8のSOAPからデータを取得する方法
- 20. IOSのURLからデータを取得する方法
- 21. PickerViewのコアデータからデータを取得する方法は? iOS
- 22. iOSのビデオからフレームを取得する方法
- 23. iosのURLからイメージサイズを取得する方法
- 24. Sinch iOSからメッセージの履歴を取得する方法は?
- 25. iOSのNSAttributedStringからHTML文字列を取得する方法
- 26. iosシステムメッセージアプリケーションのテキストフィールドからテキストを取得する方法
- 27. iOSのマップピンから位置を取得する方法
- 28. iOSのEvernoteノートからテキストを取得する方法
- 29. iosでアンインストールされたアプリケーション名を取得する方法は?
- 30. ロケーションのGPS座標を取得する
に対処するために、緯度と長い変換などの触れた場所にによる座標は、あなたがAnbu.Karthik @あなたの試したコード –
を表示することができます取得これまでのコードはありません。mapviewを持つviewcontrollerだけです。私はカスタム注釈を作成することができますが、MapViewの現在の場所を使用したいと考えています – Arda