我正试图从谷歌地图视图中的tapped位置获取CLLocationCoordinate2D对象。但它总是以-180.0,-180.0作为lat返回,长期如下:
CLLocationCoordinate2D(latitude: -180.0, longitude: -180.0)
我正在使用以下代码:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let touchpoint = touches.first
if let touch = touches.first
{
var point: CGPoint = touch.locationInView(self.view)
let touchMapCoordinate: CLLocationCoordinate2D = MyMapView.projection.coordinateForPoint(point)
}
}
答案 0 :(得分:1)
您可以使用以下GMSMapView
的委托方法。
func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
println("You have lat and long")
}