【发布时间】:2020-11-11 20:04:56
【问题描述】:
我正在使用 MapboxStatic 成功创建静态图像,并将记录的轨道坐标作为 GeoJson 数据。
我不知道如何编辑绘制在图像上的路线的颜色 - 它默认为黑色/灰色,我找不到更改它的方法。
我意识到这必须是通过编辑 GeoJson 属性本身,但我不知道如何快速编辑它?
很想了解如何以某种方式更改颜色...
let camera = SnapshotCamera(
lookingAtCenter: CLLocationCoordinate2D(latitude: self.mapView.camera.centerCoordinate.latitude, longitude: self.mapView.camera.centerCoordinate.longitude),
zoomLevel: 12)
let options = SnapshotOptions(
styleURL: self.mapView.styleURL,
camera: camera,
size: self.mapView.bounds.size)
let coordinates = self.viewModel.getTrack().locations?.map { loc -> CLLocationCoordinate2D in
CLLocationCoordinate2D(latitude: loc.latitude, longitude: loc.longitude)
}
let trackLine = MGLPolyline(coordinates: coordinates!, count: UInt(coordinates!.count))
let data = trackLine.geoJSONData(usingEncoding: String.Encoding.utf8.rawValue)
let getJson = GeoJSON(objectString: String(data: data, encoding: .utf8)!)
options.overlays.append(getJson)
【问题讨论】:
-
我使用的是 MapBox 而不是 MapKit
-
感谢@AnatolySukhanov,但事实并非如此-您链接的内容是关于将其设置在对我来说很好的实时地图上。我说的是拍摄地图的快照以创建图像。它以黑色绘制路线,我不知道如何更改它
-
抱歉,我是新手,我花了一些时间才弄明白。看我的回答。
标签: swift mapbox mapbox-ios mapbox-static-maps