浏览代码

图例动态获取全幅范围

maxiaoxiao 10 月之前
父节点
当前提交
9022c97205
共有 1 个文件被更改,包括 15 次插入3 次删除
  1. 15 3
      src/components/Combinations/LayerManage/LayerLegend.vue

+ 15 - 3
src/components/Combinations/LayerManage/LayerLegend.vue

@@ -47,8 +47,20 @@ export default {
   },
   mounted() {},
   methods: {
-    async GetLegend(vdata) {
-      let url = `${vdata.url}/legend.json?bbox=108.99,18.2,109.81,18.59`;
+    async Getbbox(vdata) {
+      let url = `${vdata.url}.json`;
+      let res = await axios.get(url);
+      if (res.data && res.data.bounds) {
+        let bbox = `
+      ${res.data.bounds.left.toFixed(2)},
+      ${res.data.bounds.bottom.toFixed(2)},
+      ${res.data.bounds.right.toFixed(2)},
+      ${res.data.bounds.top.toFixed(2)}`;
+        this.GetLegend(vdata, bbox);
+      }
+    },
+    async GetLegend(vdata, bbox) {
+      let url = `${vdata.url}/legend.json?bbox=${bbox}`;
       let res = await axios.get(url);
       let legends = [];
       res.data.layerLegends.forEach((la) => {
@@ -64,7 +76,7 @@ export default {
       this.vectors = [];
       // let vectors = this.checkeds.filter((ci) => ci.type == "Vector");
       this.checkedVector.forEach((ve) => {
-        this.GetLegend(ve);
+        this.Getbbox(ve);
       });
     },
   },