Original painting line mode:
// store a large array of point trajectory json: historyPathList for ( var I = 0; I <-historyPathList.length. 1; I ++ ) { drawColorLine (I, Color, . 4 , historyPathList); } // display the original route function drawColorLine (I, Color, weitht, List) { var Polyline = new new BMap.Polyline ([ new new BMap.Point (List [I] .lng, List [I] .lat), // starting point latitude and longitude new new BMap.Point (List [I + 1'd] .lng, List [I +. 1] .lat) // end latitude and longitude ], {strokeColor is: color, // set the color strokeWeight: weitht, // width strokeOpacity:. 1}); // transparency of the Map.addOverlay (Polyline); }
Write a lot of unnecessary points will pay more, but the API call too many times, can affect performance.
Improve:
var polylinePointsArray = []; for(var i=0;i<historyPathList.length;i++){ polylinePointsArray[i] = new BMap.Point(historyPathList[i].Lng,historyPathList[i].Lat); } var polyline = new BMap.Polyline(polylinePointsArray, {strokeColor:"green", strokeWeight:4, strokeOpacity:1}) map.addOverlay(polyline);