|
@@ -14,6 +14,7 @@ import { getArea } from "ol/sphere.js";
|
|
|
import * as proj from "ol/proj";
|
|
|
import proj4 from "proj4";
|
|
|
import { register } from "ol/proj/proj4";
|
|
|
+import GeometryCollection from 'ol/geom/GeometryCollection.js';
|
|
|
proj4.defs(
|
|
|
"EPSG:38572",
|
|
|
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs"
|
|
@@ -28,6 +29,15 @@ export let mapData = reactive({
|
|
|
isPointHide: null,
|
|
|
});
|
|
|
|
|
|
+function resetMapData(){
|
|
|
+ mapData.isEdit= false
|
|
|
+ mapData.isEditArea= false
|
|
|
+ mapData.curPointData= {}
|
|
|
+ mapData.point= null
|
|
|
+ mapData.selectPointArr= []
|
|
|
+ mapData.isPointHide= null
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* @description 地图层对象
|
|
|
*/
|
|
@@ -115,6 +125,18 @@ class AuthenticMap {
|
|
|
this.addMapSingerClick();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ fit(geometriesWkt){
|
|
|
+ let geometries = []
|
|
|
+ let f = new WKT();
|
|
|
+ for(let wkt of geometriesWkt){
|
|
|
+ geometries.push(f.readGeometry(wkt))
|
|
|
+ }
|
|
|
+ let extent = new GeometryCollection(geometries).getExtent()
|
|
|
+ this.kmap.fit(extent)
|
|
|
+ }
|
|
|
+
|
|
|
undoLastDraw() {
|
|
|
const features = this.kmap.getLayerFeatures();
|
|
|
features.forEach((feature) => {
|
|
@@ -141,9 +163,8 @@ class AuthenticMap {
|
|
|
const arrPoints = [];
|
|
|
if (points && points.length > 0) {
|
|
|
points.forEach((item) => {
|
|
|
- arrPoints.push(
|
|
|
- newPoint({ ...item, icon: "point", iconBg: "name-bg" }, "point")
|
|
|
- );
|
|
|
+ let f = newPoint({ ...item, icon: "point", iconBg: "name-bg" }, "point");
|
|
|
+ arrPoints.push(f);
|
|
|
});
|
|
|
this.clickPointLayer.source.addFeatures(arrPoints);
|
|
|
}
|
|
@@ -162,6 +183,7 @@ class AuthenticMap {
|
|
|
|
|
|
// 开始勾画
|
|
|
startDraw() {
|
|
|
+ this.kmap.setDefaultCursor("crosshair");
|
|
|
this.kmap.startDraw();
|
|
|
}
|
|
|
//结束勾画
|
|
@@ -181,10 +203,41 @@ class AuthenticMap {
|
|
|
}
|
|
|
|
|
|
// 清空单个数据
|
|
|
- clearMapData(name, val) {
|
|
|
+ clearMapData(name, val, id) {
|
|
|
mapData[name] = val;
|
|
|
+ // resetMapData()
|
|
|
+ this.clickPointLayer.source.forEachFeature((feature) => {
|
|
|
+ if (feature.get("id") === id) {
|
|
|
+ feature.set("icon", "point");
|
|
|
+ feature.set("iconBg", "name-bg");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const points = this.kmap.getLayerFeatures();
|
|
|
+ points.forEach((feature) => {
|
|
|
+ if (feature.get("id") === id) {
|
|
|
+ feature.set("icon", "point");
|
|
|
+ this.kmap.polygonStyle(feature);
|
|
|
+ mapData.isPointHide = feature;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mapData.selectPointArr = [];
|
|
|
+ }
|
|
|
+ //全选
|
|
|
+ allSelect(){
|
|
|
+ let arr = []
|
|
|
+ this.clickPointLayer.source.forEachFeature((feature) => {
|
|
|
+ feature.set("icon", "point-act");
|
|
|
+ feature.set("iconBg", "name-act-bg");
|
|
|
+ });
|
|
|
+ const points = this.kmap.getLayerFeatures();
|
|
|
+ points.forEach((feature) => {
|
|
|
+ feature.set("icon", "point-act");
|
|
|
+ this.kmap.polygonStyle(feature);
|
|
|
+ mapData.isPointHide = feature;
|
|
|
+ arr.push(feature)
|
|
|
+ });
|
|
|
+ mapData.selectPointArr = arr;
|
|
|
}
|
|
|
-
|
|
|
// 地图点击事件
|
|
|
addMapSingerClick() {
|
|
|
let that = this;
|