- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何更改 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/
所以我一直在寻找make an MGLPolyline tapable的方法。我考虑过的一种方法是使用 MapBox 添加的弹出窗口来显示某些内容,但使弹出窗口不可见,这样当某行被录制时我仍然可以执行
如何更改 MGLPolyline 的颜色?我看过here但答案不起作用。我还尝试了一些其他代码,但它太依赖苹果 map 了。那么我怎样才能改变线条的颜色,并且最好还能够编辑线条的其他方面呢?波纹管是我
我目前正在寻找一种使路线 (MGPLPolyline) 可点击的方法,以便用户可以在 Mapbox 下的两条可能路线之间进行选择。不幸的是,路线注释似乎根本不可点击: 虽然我已经正确设置了我的MGLM
刚开始使用 Mapbox,设法通过在 locationManaged didUpdateLocations 中添加它来绘制 MGLPolyline var shape = MGLPolyline
当我尝试更改 MGLPolyline 的颜色时,应用程序崩溃并打印此 fatal error (它也需要我: Assertion failed: (r_ UIColor { let arra
我试过下面的代码,但它画的是直线,我想要虚线 @IBOutlet var navigationView: MGLMapView! var polyline: MGLPolyline! overrid
是否可以使 MGLPolyLine 可触摸/可选择/具有用户交互?在我的项目中,用户需要触摸折线。有 this question之前问过,但它已经过时了大约 2 年。他们(MapBox)更新了吗? 最
我尝试使用以下代码使用适用于 iOS 的 Mapbox SDK 在 map View 上创建曲线 MGLPolyline, func lineBetweenLocation(location1: CL
在 MapBox iOS sdk 4.4.1 中,如果 MGLPolyline 穿过(180 或 -180)经度, map 会显示它绕地球的距离更长,而不是更短。 override func
我是一名优秀的程序员,十分优秀!