| | |
| | | } |
| | | } |
| | | |
| | | // 管线线段绘制方法 |
| | | // const drawLine = { |
| | | // points: [], |
| | | // color: 'red', |
| | | // L: null, |
| | | // map: null, |
| | | // layers: null, |
| | | // polyline: null, |
| | | // marker: null, |
| | | // init (map, L) { |
| | | // drawLine.L = window.L |
| | | // drawLine.map = window.map |
| | | // drawLine.points = [] |
| | | // drawLine.polyline = null |
| | | // drawLine.marker = null |
| | | // drawLine.layers = window.L.layers |
| | | // map.on('click', drawLine.click).on('dblclick', drawLine.dblclick) |
| | | // }, |
| | | // close: function (latlng) { |
| | | // /*distanceMeasure.marker = L.marker(latlng, { icon: deleteIcon }).addTo(map).on("click", function (e) { |
| | | // //console.log('marker',e); |
| | | // if(distanceMeasure.polyline) |
| | | // map.removeLayer(distanceMeasure.polyline); |
| | | // |
| | | // if(distanceMeasure.marker) |
| | | // distanceMeasure.marker.remove(); |
| | | // });*/ |
| | | // }, |
| | | // click: function (e) { |
| | | // drawLine.map.doubleClickZoom.disable() |
| | | // // 添加点信息 |
| | | // drawLine.points.push(e.latlng) |
| | | // // 添加线 |
| | | // drawLine.map.on('mousemove', drawLine.mousemove) |
| | | // }, |
| | | // mousemove (e) { |
| | | // drawLine.points.push(e.latlng) |
| | | // if (drawLine.polyline) { |
| | | // distanceMeasure.map.removeLayer(distanceMeasure.polyline) |
| | | // } |
| | | // drawLine.polyline = drawLine.L.polyline(drawLine.points, { |
| | | // showMeasurements: false, |
| | | // color: 'red' |
| | | // }) |
| | | // drawLine.polyline.addTo(drawLine.layers) |
| | | // // distanceMeasure.polyline.enableEdit() |
| | | // drawLine.layers.addTo(drawLine.map) |
| | | // drawLine.points.pop() |
| | | // }, |
| | | // dblclick (e) { // 双击结束 |
| | | // console.log(drawLine.polyline.dragging) |
| | | // console.log('双击结束', e) |
| | | // drawLine.polyline.enableEdit() |
| | | // drawLine.polyline.dragging.disable() |
| | | // drawLine.polyline.addTo(drawLine.layers) |
| | | // drawLine.map.on('editable:vertex:drag editable:vertex:deleted', drawLine.polyline.updateMeasurements, drawLine.polyline) |
| | | // drawLine.close(e.latlng) |
| | | // drawLine.map.off('click', drawLine.click).off('mousemove', drawLine.mousemove).off('dblclick', drawLine.dblclick) |
| | | // }, |
| | | // destory: function () { |
| | | // if (drawLine.polyline) { |
| | | // drawLine.map.removeLayer(drawLine.polyline) |
| | | // } |
| | | // if (drawLine.marker) { |
| | | // drawLine.marker.remove() |
| | | // } |
| | | // if (drawLine.layers) { |
| | | // drawLine.layers.clearLayers() |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | const startMeasureArea = function (map, L) { |
| | | areaMeasure.destory() |
| | | areaMeasure.init(map, L) |
| | |
| | | distanceMeasure.init(map, L) |
| | | } |
| | | |
| | | // const drawLineData = (map, L) => { |
| | | // drawLine.destory() |
| | | // drawLine.init(map, L) |
| | | // } |
| | | |
| | | const clearMeasure = function () { |
| | | areaMeasure.destory() |
| | | distanceMeasure.destory() |
| | | // drawLine.destory() |
| | | } |
| | | export default { |
| | | startMeasureArea, |
| | | startMeasureLen, |
| | | clearMeasure |
| | | // drawLineData |
| | | } |