import config from "@/api/config.js"; import * as KMap from "@/utils/ol-map/KMap"; import { newAreaFeature } from "@/utils/util"; /** * @description 地图层对象 */ class BlueRegionLayer { constructor(map) { let that = this; this.vectorStyle = new KMap.VectorStyle(); this.blueRegionLayer = new KMap.VectorLayer("blueRegionLayer", 99, { minZoom: 15, }); map.addLayer(this.blueRegionLayer.layer); this.kmap = map } initData(arr,opacity='') { if (this.blueRegionLayer) { this.blueRegionLayer.source.clear(); } if(arr.length>0){ for (let item of arr) { let feature = newAreaFeature(item); let strokeColor = "#FFFFFF"; feature.setStyle(this.vectorStyle.getPolygonStyle(item.color+opacity, strokeColor, 1)); this.blueRegionLayer.addFeature(feature); } this.kmap.fit(this.blueRegionLayer.source.getExtent(), {padding:[100,100,100,100]}); } } } export default BlueRegionLayer;