|
@@ -619,12 +619,8 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import proj4 from "@/components/proj4/index.js";
|
|
|
-import GeoJSON from "ol/format/GeoJSON";
|
|
|
import { esriConfig, appconfig } from "staticPub/config";
|
|
|
import request from "@/utils/request";
|
|
|
-import { getMaterialList, getAvgPress } from "@/api/DMA/zoningManage";
|
|
|
-import { queryDevice } from "@/api/scadaApi";
|
|
|
import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer";
|
|
|
import { OSM, XYZ, Vector as VectorSource } from "ol/source";
|
|
|
import {
|
|
@@ -636,6 +632,7 @@ import {
|
|
|
Stroke,
|
|
|
Text,
|
|
|
} from "ol/style";
|
|
|
+import { Select, Pointer, Draw, Modify } from "ol/interaction";
|
|
|
import olMap from "@/views/components/olMap/index.vue";
|
|
|
import { getArea, getLength } from "ol/sphere";
|
|
|
import ol from "ol";
|
|
@@ -716,6 +713,10 @@ export default {
|
|
|
geoservers: mapConfig.geoservers || [],
|
|
|
vectorSource: null,
|
|
|
vectorLayer: null,
|
|
|
+ editVectorSource:null,
|
|
|
+ editVectorLayer: null,
|
|
|
+ editSelect:null,
|
|
|
+ editModify:null
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -896,6 +897,10 @@ export default {
|
|
|
this.lineColor = geo.symbol.outline.color; //边线颜色
|
|
|
this.opacity = geo.symbol.opacity; //透明度
|
|
|
this.polygonColor = geo.symbol.color;
|
|
|
+ this.polygon = null;
|
|
|
+ const rings = geo.hasOwnProperty("rings") ? geo.rings : null;
|
|
|
+ if (rings == null) return;
|
|
|
+ this.polygon = new WKT().readFeature(rings);
|
|
|
} else {
|
|
|
this.deleteDraw();
|
|
|
}
|
|
@@ -1216,7 +1221,89 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- editDraw() {},
|
|
|
+ /**
|
|
|
+ * 分区图形编辑
|
|
|
+ */
|
|
|
+ editDraw() {
|
|
|
+ if (this.polygon == null) return;
|
|
|
+ this.removeEditFeature();
|
|
|
+ this.removeEditVectorLayer();
|
|
|
+ let map = this.$refs.olmap.map;
|
|
|
+ this.editVectorSource = new VectorSource({ wrapX: false });
|
|
|
+ this.editVectorLayer = new VectorLayer({
|
|
|
+ source: this.editVectorSource,
|
|
|
+ style: new Style({
|
|
|
+ //边框样式
|
|
|
+ stroke: new Stroke({
|
|
|
+ color: "blue",
|
|
|
+ width: 3,
|
|
|
+ }),
|
|
|
+ //填充样式
|
|
|
+ fill: new Fill({
|
|
|
+ color: "rgba(0, 0, 255, 0.3)",
|
|
|
+ }),
|
|
|
+ }),
|
|
|
+ });
|
|
|
+ map.addLayer(this.editVectorLayer);
|
|
|
+ this.editVectorSource.addFeature(this.polygon);
|
|
|
+ // 先选择在修改.每次只编辑一个图形
|
|
|
+ this.editSelect = new Select({
|
|
|
+ layers: [this.editVectorLayer],
|
|
|
+ feature: this.editVectorSource.getFeatures(),
|
|
|
+ });
|
|
|
+ map.addInteraction(this.editSelect);
|
|
|
+ // 传入选中的图形
|
|
|
+ // 这样做之后,需要点击选中要素才可以进行编辑
|
|
|
+ this.editModify = new Modify({
|
|
|
+ features: this.editSelect.getFeatures(),
|
|
|
+ });
|
|
|
+
|
|
|
+ this.editModify.on('modifyend',(evt)=>{
|
|
|
+ let feature = evt.features.array_[0]
|
|
|
+ this.drawFeature = feature
|
|
|
+ if (this.drawFeature) {
|
|
|
+ this.isHavePolygon = true;
|
|
|
+ this.queryFeaturesByPolygon();
|
|
|
+ this.polygon = feature;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ map.addInteraction(this.editModify);
|
|
|
+ this.editSelect.setActive(true);
|
|
|
+ this.editModify.setActive(true);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移除feature
|
|
|
+ */
|
|
|
+ removeEditFeature() {
|
|
|
+ let that = this;
|
|
|
+ if (this.editVectorLayer) {
|
|
|
+ that.editVectorLayer
|
|
|
+ .getSource()
|
|
|
+ .getFeatures()
|
|
|
+ .forEach((feature) => {
|
|
|
+ that.editVectorLayer.getSource().removeFeature(feature);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移除VectorLayer
|
|
|
+ */
|
|
|
+ removeEditVectorLayer() {
|
|
|
+ if (this.editVectorLayer) {
|
|
|
+ let that = this;
|
|
|
+ let map = this.$refs.olmap.map;
|
|
|
+ that.editVectorLayer
|
|
|
+ .getSource()
|
|
|
+ .getFeatures()
|
|
|
+ .forEach((feature) => {
|
|
|
+ that.editVectorLayer.getSource().removeFeature(feature);
|
|
|
+ });
|
|
|
+ that.features = [];
|
|
|
+ map.removeLayer(that.editVectorLayer);
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
editCancel() {},
|
|
|
|