gpt4 book ai didi

ios - 无法在 swift 中调用非函数类型 'CLLocationCordinate2d' 的值

转载 作者:行者123 更新时间:2023-11-28 10:21:14 25 4
gpt4 key购买 nike

我正在尝试向 map 添加两个注释。该 map 工作正常,但当我尝试添加注释时,出现上述错误。这是与此相关的代码部分。

//temporary nearby locations list

//temple tooth
var templeToothMarker = MKPointAnnotation()
var templeToothLocation = CLLocationCoordinate2D(latitude: 7.294715, longitude: 80.639858)
templeToothMarker.coordinate(templeToothLocation)
templeToothMarker.title = "Kandy Dalada Maligawa"
templeToothMarker.subtitle = "Historic Religious place"

//botanical gardens

var botanicalGardenMarker = MKPointAnnotation()
var botanicalGardenLocation = CLLocationCoordinate2D(latitude: 7.294715, longitude: 80.639858)
botanicalGardenMarker.coordinate(templeToothLocation)
botanicalGardenMarker.title = "Royal Botanical Gardens"
botanicalGardenMarker.subtitle = "Historic Religious place"

//load markers to map
map.addAnnotations([templeToothMarker, botanicalGardenMarker])

错误出现在

templeToothMarker.coordinate(templeToothLocation)

BotanicalGardenMarker.coordinate(templeToothLocation)

行。我感到困惑,因为我将正确类型的参数传递给 coordinate 方法。这里可能出了什么问题?

最佳答案

这很简单。坐标它是一个属性,而不是一个方法。你只需要设置如下:

botanicalGardenMarker.coordinate = botanicalGardenLocation

关于ios - 无法在 swift 中调用非函数类型 'CLLocationCordinate2d' 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34773736/

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