Js代码
function change_map(longitude, latitude) { var mp = new BMap.Map("container"); var point = new BMap.Point(longitude, latitude); mp.centerAndZoom(point, 15); mp.enableScrollWheelZoom(); mp.enableKeyboard(); mp.enableContinuousZoom(); mp.enableInertialDragging(); mp.addControl(new BMap.NavigationControl()); mp.addControl(new BMap.ScaleControl()); mp.addControl(new BMap.OverviewMapControl()); window.mp = mp; }4.百度地图添加折线。
Js代码
//向地图中添加线函数 function addPolyline(from_longitude, from_latitude , to_longitude, to_latitude) { var line = new BMap.Polyline( [ new BMap.Point(from_longitude, from_latitude), new BMap.Point(to_longitude, to_latitude) ], { strokeStyle : "dashed", strokeWeight : 2, strokeColor : "blue", strokeOpacity : 0.6 }); mp.addOverlay(line); }