| | |
| | | // eslint-disable-next-line no-unused-vars |
| | | defaults as OlControlDefaults, |
| | | defaults, |
| | | // 全屏控件 |
| | | FullScreen, |
| | | // 比例尺控件 |
| | | ScaleLine, |
| | | // 缩放滚动条控件 |
| | | // eslint-disable-next-line no-unused-vars |
| | | ZoomSlider, |
| | | // 鼠标位置控件 |
| | | // eslint-disable-next-line no-unused-vars |
| | | MousePosition, |
| | | // -地图属性控件 |
| | | Attribution, |
| | | // 鹰眼控件 |
| | | // eslint-disable-next-line no-unused-vars |
| | | OverviewMap, |
| | | // 缩放到范围控件 |
| | | // eslint-disable-next-line no-unused-vars |
| | | ZoomToExtent, |
| | | Rotate |
| | | } from "ol/control.js"; |
| | | |
| | | import VectorLayer from "ol/layer/Vector"; |
| | |
| | | zIndex: 22, |
| | | source: new VectorSource() |
| | | }), |
| | | // peopleLineAddlayer: new VectorLayer({ |
| | | // // 图标图层 |
| | | // zIndex: 22, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | beginsPoint: new VectorLayer({ |
| | | // 图标图层 |
| | | zIndex: 22, |
| | |
| | | source: new VectorSource() |
| | | }), |
| | | peopleLineAddlayer: null, |
| | | |
| | | // 存储新增点,线,面,数据的地方 |
| | | // polygonData: [], |
| | | // polygonFlag: false, |
| | | // editToolbar: null, |
| | | // addPolygonEntitys: null, |
| | | |
| | | // typeSelected: "LineString", |
| | | typeSelected: "Polygon", |
| | | // drawLayer: null, |
| | | draw: null, |
| | |
| | | }, |
| | | computed: { |
| | | openDrawChiose() { |
| | | // console.log( |
| | | // "this.openDrawLine:", |
| | | // this.openDrawLine, |
| | | // "this.openDrawPoint:", |
| | | // this.openDrawPoint |
| | | // ); |
| | | if (this.openDrawLine) { |
| | | return "openDrawLine"; |
| | | } else if (this.openDrawPoint) { |
| | |
| | | }); |
| | | ol2d.addInteraction(this.draw); |
| | | this.draw.on("drawend", function(evt) { |
| | | // console.log(evt, 3); |
| | | that.drawingEnd(evt); |
| | | }); |
| | | }, |
| | |
| | | points[0].map(item => { |
| | | that.polygon.push({ lng: item[0], lat: item[1] }); |
| | | }); |
| | | // console.log(that.polygon, 1111); |
| | | |
| | | that.$store.commit("setpolygon", that.polygon); //用vuex传最终数据 |
| | | //重新画面 |
| | | that.addLines(that.polygon, "mian"); |
| | |
| | | }, |
| | | onceOnlodad(ourDatas) { |
| | | this.ourDatas = ourDatas; |
| | | console.log(ourDatas); |
| | | }, |
| | | //old |
| | | //加载底层路线和图标 |
| | |
| | | }, |
| | | // 若没有value数据,删除地图上的元素 |
| | | deleteElement(name, id) { |
| | | // console.log(name, id); |
| | | // this.ourLayer[name + id].getSource().clear(); |
| | | for (let k in this.ourLayer) { |
| | | this.ourLayer[k].getSource().clear(); |
| | | } |
| | |
| | | var entityArr = []; |
| | | if (notdo) { |
| | | entityArr = data; |
| | | console.log(entityArr, "notdo"); |
| | | } else { |
| | | for (let kd in data) { |
| | | entityArr.push([Number(data[kd].lng), Number(data[kd].lat)]); |
| | | } |
| | | } |
| | | // console.log(entityArr); |
| | | var lineCoords = entityArr; // 线里点的集合 |
| | | // console.log(lineCoords); |
| | | var feature_LineString = new Feature({ |
| | | //线面板 |
| | | geometry: new LineString(lineCoords) |
| | |
| | | //面 |
| | | //解析面数据 |
| | | let mianData = [lineCoords]; |
| | | // console.log(mianData); |
| | | // return; |
| | | var feature_Polygon = new Feature({ |
| | | //面面板 |
| | | geometry: new Polygon(mianData) |
| | |
| | | this.layermian.getSource().addFeature(feature_Polygon); |
| | | //保存图层 |
| | | ol2d.addLayer(this.layermian); |
| | | // console.log(this.ourLayer, 88888); |
| | | }, |
| | | |
| | | //上面是初始化················· |
| | |
| | | } |
| | | this.nowIndex = num; |
| | | if (val.indexOf("路径") != -1) { |
| | | // console.log("加载路径按钮"); |
| | | this.controlBut("openDrawLine", this.notNow); |
| | | } else { |
| | | // console.log("加载标点按钮"); |
| | | this.controlBut("openDrawPoint", this.notNow); |
| | | } |
| | | }, |
| | |
| | | //确认数据 |
| | | useMapData() { |
| | | //返回用数据 |
| | | // console.log(this.openDrawChiose, this.nowIndex); |
| | | this.$parent.MapDataShow = false; |
| | | let val; |
| | | if (this.openDrawChiose == "openDrawLine") { |
| | |
| | | } |
| | | |
| | | var lineCoords = entityArr; // 线里点的集合 |
| | | //移动位置---暂不需要 |
| | | // var view = ol2d.getView(); |
| | | // view.setCenter([ |
| | | // lineCoords[Math.ceil(entityArr.length / 2)][0], |
| | | // lineCoords[Math.ceil(entityArr.length / 2)][1], |
| | | // ]); |
| | | // view.setZoom(14.5); |
| | | |
| | | // 要素 |
| | | var feature_LineString = new Feature({ |