blueRegionLayer.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import config from "@/api/config.js";
  2. import * as KMap from "@/utils/ol-map/KMap";
  3. import { newAreaFeature } from "@/utils/util";
  4. /**
  5. * @description 地图层对象
  6. */
  7. class BlueRegionLayer {
  8. constructor(map) {
  9. let that = this;
  10. this.vectorStyle = new KMap.VectorStyle();
  11. this.blueRegionLayer = new KMap.VectorLayer("blueRegionLayer", 99, {
  12. minZoom: 15,
  13. });
  14. map.addLayer(this.blueRegionLayer.layer);
  15. this.kmap = map
  16. }
  17. initData(arr,opacity='') {
  18. if (this.blueRegionLayer) {
  19. this.blueRegionLayer.source.clear();
  20. }
  21. if(arr.length>0){
  22. for (let item of arr) {
  23. let feature = newAreaFeature(item);
  24. let strokeColor = "#FFFFFF";
  25. feature.setStyle(this.vectorStyle.getPolygonStyle(item.color+opacity, strokeColor, 1));
  26. this.blueRegionLayer.addFeature(feature);
  27. }
  28. this.kmap.fit(this.blueRegionLayer.source.getExtent(), {padding:[100,100,100,100]});
  29. }
  30. }
  31. }
  32. export default BlueRegionLayer;