Ver Fonte

修改环境

shuhao há 4 meses atrás
pai
commit
9729bad132
1 ficheiros alterados com 14 adições e 1 exclusões
  1. 14 1
      src/utils/ol-map/Map.js

+ 14 - 1
src/utils/ol-map/Map.js

@@ -18,7 +18,7 @@ import {Feature} from "ol";
 import {GeoJSON, WKT} from 'ol/format'
 import { Style, Text,Icon } from 'ol/style';
 import { Circle, Fill, Stroke } from 'ol/style.js';
-import { LineString, Point } from 'ol/geom';
+import {LineString, MultiPolygon, Point} from 'ol/geom';
 import {getArea} from "ol/sphere"
 /**
  * @description KMap.Map 地图类
@@ -375,6 +375,19 @@ class Map {
 		vm.polygonLayer.source.addFeatures(new GeoJSON().readFeatures(geometry))
 	}
 
+	setLayerPolygonCoordinates(coordinates, layout ,data, isView, padding) {
+		const vm = this
+		let f = new Feature({geometry:new MultiPolygon([[coordinates]],layout) ,...data})
+		if(f.get("id")){
+			f.setId(f.get("id"))
+		}
+		const extent = f.getGeometry().getExtent()
+		vm.polygonLayer.source.addFeature(f)
+		if(isView){
+			vm.map.getView().fit(extent, { padding: padding || [20, 20, 20, 20] });
+		}
+	}
+
 	setLayerWkt(wkt,data,isView, padding) {
 		const vm = this
 		let f = new Feature({geometry:new WKT().readGeometry(wkt),...data})