百度地图折线覆盖物添加起点和终点??
//添加时
map1.addEventListener("click", function (e) { if (doDraw == 0) { //判断是否绘制曲线完毕 var point = new BMap.Point(e.point.lng, e.point.lat); points.push(point); //存储曲线上每个点的经纬度 var polyline = new BMap.Polyline(points, { strokeColor: "red", strokeWeight: 3, strokeOpacity: 0.5 }); map1.addOverlay(polyline); v_ReservoirArea += e.point.lng + "," + e.point.lat + ";"; $("#txt_Coordinate").textbox('setValue', v_ReservoirArea);//获取经纬度到文本框,已空格隔开 var marker = new BMap.Marker(points[0]); marker.setLabel(new BMap.Label("起点")); map1.addOverlay(marker); } }); map1.addEventListener("dblclick", function (e) { //当鼠标双击时:结束绘制, var paths = points.length; var marker1 = new BMap.Marker(points[paths - 1]); marker1.setLabel(new BMap.Label("终点")); map1.addOverlay(marker1); alert("绘制完成!"); doDraw = 1; }); //修改时 var sPoint = opticalCoordinate.split(";"); if (sPoint != null && sPoint != "") { var se = []; for (var j = 0; j < sPoint.length; j++) { var pointItem = sPoint[j].split(","); if (pointItem != null && pointItem != "") { var Lon = pointItem[0]; var Lat = pointItem[1]; se.push(new BMap.Point(Lon, Lat)); } } //map1 = new BMap.Map("OpticalMap"); // 创建Map实例 //map1.centerAndZoom(new BMap.Point(se[0].lng,se[0].lat), 11); // 初始化地图,设置中心点坐标和地图级别 //map1.addControl(new BMap.NavigationControl());//左上角,添加默认缩放平移控件 //map1.addControl(new BMap.MapTypeControl()); //添加地图类型控件 //map1.setCurrentCity(v_CityName); // 设置地图显示的城市 此项是必须设置的 //map1.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 var polyline = new BMap.Polyline(se, { strokeColor: "red", strokeWeight: 3, strokeOpacity: 0.5 }); map1.addOverlay(polyline); var marker = new BMap.Marker(se[0]); marker.setLabel(new BMap.Label("起点")); map1.addOverlay(marker); var paths = se.length; var marker1 = new BMap.Marker(se[paths - 1]); marker1.setLabel(new BMap.Label("终点")); map1.addOverlay(marker1);