gpt4 book ai didi

ios - 如何在 Google Map iOS Swift 中获取点击位置的经纬度

转载 作者:行者123 更新时间:2023-11-29 00:46:54 24 4
gpt4 key购买 nike

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

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

最佳答案

您可以使用以下 GMSMapView 的委托(delegate)方法。

func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
println("You have lat and long")
}

关于ios - 如何在 Google Map iOS Swift 中获取点击位置的经纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38530470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com