我想检索 MKPolyline,但我的代码不断返回 MKShape。我正在尝试使用此处描述的 GEOSwift 库: https ://github.com/GEOSwift/GEOSwift
我的代码:
let linestring = Geometry.create("LINESTRING(51.063164 -0.728986, 51.072347 -0.723721, 51.116898 -0.731893)")!
let shapeLine = linestring.mapShape()
self.mapView.add(shapeLine)
我收到错误:无法使用类型为“(MKShape)”的参数列表调用“添加”
(让 shapeLine = linestring.mapshape() 应该将其转换为 MKPolyline)
但是,如果我运行:
let linestring = Geometry.create("LINESTRING(51.063164 -0.728986, 51.072347 -0.723721, 51.116898 -0.731893)")!
let shapeLine = linestring.mapShape()
dump(shapeLine)
我明白了:
- <MKPolyline: 0x60000069e550> #0
- super: MKMultiPoint
- super: MKShape
- super: NSObject
这是说那里有一条折线吗?
我的叠加渲染器:
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = UIColor.blue
renderer.lineWidth = 5.0
return renderer
}
另外,我已经有其他折线在这个应用程序上工作。我已设置 MKMapViewDelegate 并将委托设置为 self。
///为了避免xy问题 - 我试图沿着一条路线搜索,所以我使用GEOSwift在折线周围创建缓冲区,然后使用它来搜索具有这些点的地理查询的数据库,下面是描述的具体问题在标题中:///
我确定错误很简单,但是我看了很长时间相同的代码,我只是看不到它。
任何帮助深表感谢