0

我正在尝试从谷歌地图视图中的点击位置获取 CLLocationCoordinate2D 对象。但它总是返回我 -180.0, -180.0 作为纬度,长这样:

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)
     }
}
4

1 回答 1

2

您可以使用以下委托方法GMSMapView

func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
    println("You have lat and long")
}
于 2016-07-22T15:42:28.493 回答