このようなあなたのアドレスを取得します: -
func getAddressForLatLng(latitude: CLLocationDegrees, longitude: CLLocationDegrees, completionBlock : ((addrs : String)->Void)) {
let url = NSURL(string: "\(baseUrl)latlng=\(latitude),\(longitude)&key=\(serverKey)")
print(url)
let data = NSData(contentsOfURL: url!)
let json = try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as! NSDictionary
if let result = json["results"] as? NSArray {
if let address = result[0]["address_components"] as? NSArray {
let number = address[0]["short_name"] as! String
let street = address[1]["short_name"] as! String
let city = address[2]["short_name"] as! String
let state = address[4]["short_name"] as! String
let zip = address[6]["short_name"] as! String
print("\(number) \(street), \(city), \(state) \(zip)")
completionBlock(addrs: "\(number) \(street), \(city), \(state) \(zip)")
}
}
}
あなたdidLongPressAtCoordinate機能を更新します -
func mapView(mapView: GMSMapView!, didLongPressAtCoordinate coordinate: CLLocationCoordinate2D) {
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)
self.googleMapsView.clear()
self.googleMapsView.myLocationEnabled = false
marker.map = self.googleMapsView
getAddressForLatLng(coordinate.latitude, longitude: coordinate.longitude) { (addrs) in
marker.title = addrs
marker.snippet = "\(coordinate.latitude),\(coordinate.longitude)"
}
}
マインド: - baseUrlにそしてサーバキーをGoogleコンソールbaseUrlにあり、 serverKey
Hey scbas1000、スタックオーバーフローへようこそ。あなたの質問は非常に曖昧で、答えが出る可能性はほとんどありません。 [質問する](http://stackoverflow.com/help/how-to-ask)のガイドをご覧ください。 – Alexander
あなたの注意のおかげで、私はそれを編集する、今はそれが正しいと思うです – scbas1000
@ scbas1000いいえ、あなたの質問はまだ非常に曖昧であり、あなたはこれまで持っているものを示すコードを掲載していません。あなたが持っているコードを投稿してください。分で作業していることを明確に議論し、達成しようとしているもの(例が役に立ちます)を見つけて、エラー/問題を挙げてください。 –