百度地圖軌跡
function guigui(){ //alert("fdhkj"); // 百度地圖定義中心點 map.centerAndZoom(new BMap.Point(116.404, 39.915), 15); // 百度地圖滾輪可縮放 map.enableScrollWheelZoom(); // 複雜的自定義覆蓋物(建構函式) function ComplexCustomOverlay(point, text, mouseoverText,index,linetext,linecolor){ this._point = point; // 經緯度 // this._text = text; // 顯示文字 // this._overText = mouseoverText; // 滑鼠移入後顯示的文字 this._index = index // 表示第幾個點 this._linetext = linetext; this._linecolor = linecolor; } ComplexCustomOverlay.prototype = new BMap.Overlay();// 繼承百度覆蓋物 ComplexCustomOverlay.prototype.initialize = function(map){ this._map = map; var div = this._div = document.createElement("div"); div.style.position = "absolute"; div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat); div.style.backgroundColor = this._linecolor; div.style.color = "red"; div.style.height = "20px";//圓點的大小 div.style.width = "20px";//圓點的大小 div.style.borderRadius = '50%'; div.style.whiteSpace = "nowrap"; div.style.MozUserSelect = "none"; div.style.fontSize = "12px"; div.style.opacity = 1; div.className = 'circleDiv'+this._linetext+this._index +' animated pulse infinite' map.getPanes().labelPane.appendChild(div); return div; } ComplexCustomOverlay.prototype.draw = function(){ var map = this._map; var pixel = map.pointToOverlayPixel(this._point); this._div.style.left = pixel.x +40 + "px"; this._div.style.top = pixel.y + "px"; } var date = [{'linedata': [39.91901, 39.918101 ,39.917101, 39.916101, 39.915101, 39.914101, 39.913101, 39.122101, 39.911101, 39.910101, 39.909101, 39.905758],'linecolor':'blue','linetext':'line2'} ]; var date1 = [116.407845, 116.407845 ,116.407845, 116.407845, 116.407845, 116.407845, 116.407845,116.407845, 116.407845, 116.407845, 116.407845,116.428362]; date.forEach(function(value){ adddot(value) }) function adddot(data){ // 一條線路的打點 var i; for (i in data.linedata) { //for (var c in data2.lin){ // 閉包 (function(i,data) { setTimeout(function() { // 每隔3s建立一個點 var myCompOverlay = new ComplexCustomOverlay(new BMap.Point(date1[i],data.linedata[i]), "",'mousetext',i,data.linetext,data.linecolor); map.addOverlay(myCompOverlay); }, i*(10/data.linedata.length)*3000); })(i,data) } } }