【发布时间】:2016-04-26 08:29:59
【问题描述】:
我正在为我的应用程序使用 MapBox。我需要在当前位置和给定标记之间画一条直线。每次位置更新都应更新此行。所以我写了这段代码
func mapView(mapView: MGLMapView, didUpdateUserLocation userLocation: MGLUserLocation?){
drawPath()
}
func drawPath(){
if(shouldDrawLine){
mapView.removeOverlay(line)
let userLoaction = mapView.userLocation!.coordinate
linePoints = [userLoaction, destination]
shouldDrawLine = true
line = MGLPolyline(coordinates: &linePoints, count: 2)
mapView.addOverlay(line)
}
}
我得到了这样的图片:
但它太落后了!黑线每隔几秒钟闪烁一次。
如何优化它?
【问题讨论】: