gpt4 book ai didi

ios - 如何更改 MGLPolyline 的颜色?

转载 作者:行者123 更新时间:2023-11-29 06:01:58 25 4
gpt4 key购买 nike

如何更改 MGLPolyline 的颜色?我看过here但答案不起作用。我还尝试了一些其他代码,但它太依赖苹果 map 了。那么我怎样才能改变线条的颜色,并且最好还能够编辑线条的其他方面呢?波纹管是我相信我应该进行这些编辑的代码的地方,但我不是 100%。

        @objc func useButtonTap(_ sender: UIGestureRecognizer) {
print("use tap button pressed")
startButton.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.9)
useTrackButton.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.9)

locationManager?.stopUpdatingLocation()

print(locationList, "<-- location manager array in use button")
if locationList == [] {
print("nothing was tracked")
} else {

var mapCoordinates: [CLLocationCoordinate2D] = []

for locationT in locationList {
print(locationT, "<-- locationT")
print(locationT.coordinate.latitude, "<-- latitude")
print(locationT.coordinate.longitude, "<-- longitude")

let locationLatitude = locationT.coordinate.latitude
let locationLongitude = locationT.coordinate.longitude

print(locationLatitude, "lat")
print(locationLongitude, " long")
let newCoord = CLLocationCoordinate2D(latitude: locationLatitude, longitude: locationLongitude) // - (0.0001/2)
print(newCoord, "<-- new coord")
mapCoordinates.append(newCoord)//+ 0.0001

}

polyline = MGLPolyline(coordinates: mapCoordinates, count: UInt(mapCoordinates.count))
// toCome = polyline
// mapView.add(polyline)

mapView.addAnnotation(polyline) //used to be jsut .add, changed in order to try anwser for color chaning of polyline

}
}

最佳答案

你必须使mapView.delegate = self

然后实现这个方法:

func mapView(_ mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {

return .blue
}

关于ios - 如何更改 MGLPolyline 的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54566855/

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