0
我想從谷歌地圖視圖中的龍頭位置獲取CLLocationCoordinate2D對象。但是,它總是返回我-180.0,-180.0爲緯度,經度是這樣的:如何在谷歌地圖中獲取緯度龍頭位置Swift
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)
}
}
這是在swift 3中工作嗎?因爲這永遠不會觸發我。 – Neo42
@ Neo42查看文檔(位於https://stackoverflow.com/questions/38530470/how-to-get-lat-long-of-tapped-location-in-google-map-ios-swift)是的,這應該適用於Swift 3.你有'GMSMapView'委託集嗎? – BergQuester