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

Cannot call value of non-function type 'CLLocationCordinate2d' in swift

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

//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