executeBlueRegion.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="bottom-map" ref="areaRef"></div>
  3. </template>
  4. <script setup>
  5. import Layer from "ol/layer/Vector";
  6. import config from "@/api/config.js";
  7. import { newAreaFeature } from "@/common/util";
  8. import * as KMap from "@/utils/ol-map/KMap";
  9. import Stroke from "ol/style/Stroke";
  10. import * as util from "@/common/ol_common.js";
  11. import Style from "ol/style/Style";
  12. import Icon from "ol/style/Icon";
  13. import { Point } from "ol/geom";
  14. import Feature from "ol/Feature";
  15. import WKT from "ol/format/WKT";
  16. import { onMounted, ref } from "vue";
  17. const props = defineProps({
  18. executeBlueZones: {
  19. type: String,
  20. required: true,
  21. },
  22. executeBlueZones: {}
  23. });
  24. const areaRef = ref(null);
  25. const initMap = () => {
  26. let executeBlueZones = props.executeBlueZones
  27. let vectorStyle = new KMap.VectorStyle();
  28. // 位置图标
  29. let blueRegionLayer = new KMap.VectorLayer("blueRegionLayer", 99999, {
  30. minZoom: 1,
  31. maxZoom: 22,
  32. });
  33. let level = 16;
  34. let coordinate = util.wktCastGeom("POINT(113.6142086995688 23.585836479509055)").getFirstCoordinate();
  35. let kmap = new KMap.Map(areaRef.value, level, coordinate[0], coordinate[1], null, 1, 22, "img", false, false);
  36. kmap.addLayer(blueRegionLayer.layer);
  37. let xyz = config.base_img_url + "map/lby/{z}/{x}/{y}.png";
  38. kmap.addXYZLayer(xyz, { minZoom: 8, maxZoom: 22 }, 2);
  39. // let xyz2 = config.base_img_url3 + "map/lby/{z}/{x}/{y}.png";
  40. // kmap.addXYZLayer(xyz2, { minZoom: 8, maxZoom: 22 }, 2);
  41. VE_API.farm.blueRegionList({ farmId: 766 }).then(({ data, code }) => {
  42. console.log("dat22222a", executeBlueZones);
  43. for (let item of data) {
  44. executeBlueZones.map((zone) => {
  45. if (zone.id === item.blueZoneCode) {
  46. item.wkt = item.geom;
  47. item.id = item.blueZoneCode;
  48. let feature = newAreaFeature(item);
  49. blueRegionLayer.addFeature(feature);
  50. }
  51. });
  52. }
  53. kmap.fit(blueRegionLayer.source.getExtent(), [0, 0, 0, 0]);
  54. kmap.addLayer(blueRegionLayer.layer);
  55. });
  56. // VE_API.temp.tempBlueRegionList().then(({ data, code }) => {
  57. // console.log("ddd", data);
  58. // for (let item of data) {
  59. // let feature = newAreaFeature(item);
  60. // let blueRegionLevel = executeBlueRegion.find((executeBlueRegionItem) => {
  61. // return executeBlueRegionItem.id === parseInt(item.id);
  62. // });
  63. // let fillColor = "";
  64. // let strokeColor = "#2199F8";
  65. // if (blueRegionLevel && blueRegionLevel.level == 1) {
  66. // fillColor = strokeColor + "40";
  67. // strokeColor += "40";
  68. // } else if (blueRegionLevel && blueRegionLevel.level == 2) {
  69. // fillColor = strokeColor + "90";
  70. // strokeColor += "90";
  71. // } else {
  72. // fillColor = "rgba(111,110,110,0.50)";
  73. // strokeColor = "rgba(111,110,110,0.50)";
  74. // }
  75. // feature.setStyle(vectorStyle.getPolygonStyle(fillColor, strokeColor, 1));
  76. // blueRegionLayer.addFeature(feature);
  77. // }
  78. // kmap.fit(blueRegionLayer.source.getExtent(), [0, 0, 0, 0]);
  79. // });
  80. };
  81. const getBlueRegion = (executeBlueZones) => {
  82. };
  83. onMounted(() => {
  84. initMap();
  85. });
  86. </script>
  87. <style scoped>
  88. .bottom-map {
  89. width: 100%;
  90. height: 150px;
  91. border-radius: 8px;
  92. }
  93. </style>