首页 > 其他分享 >使用L7·蚂蚁地理空间数据可视化实现灯杆查看

使用L7·蚂蚁地理空间数据可视化实现灯杆查看

时间:2024-04-11 16:24:47浏览次数:12  
标签:node min 灯杆 scene clusterMarkerLayer 空间数据 L7 max defineKey

 

  1 <template>
  2   <div v-if="showMapDialog">
  3     <el-dialog title="查看灯杆分布" :visible="visible" @close="closeDia">
  4       <div id="map"></div>
  5     </el-dialog>
  6   </div>
  7 </template>
  8 
  9 <script>
 10 import { Scene, Marker, MarkerLayer, PointLayer, Popup } from "@antv/l7";
 11 import { GaodeMap } from "@antv/l7-maps";
 12 import locationImg from "@/modules/intelLamp/assets/image/icon-light.png";
 13 export default {
 14   props: {
 15     showMapDialog: {
 16       type: Boolean,
 17       default() {
 18         return false; // 帐号状态 true正常 false异常
 19       }
 20     },
 21     coordinateList: {
 22       type: Array,
 23       default() {
 24         return [];
 25       }
 26     }
 27   },
 28   data() {
 29     return {
 30       scene: null,
 31       visible: false,
 32       clusterMarkerLayer: null
 33     };
 34   },
 35   watch: {
 36     showMapDialog(val) {
 37       this.visible = val;
 38       if (this.visible) {
 39         this.$nextTick(() => {
 40           this.initMap();
 41         });
 42       }
 43     }
 44   },
 45   beforeDestroy() {
 46     if (this.scene) {
 47       this.scene.destroy();
 48     }
 49   },
 50   methods: {
 51     closeDia() {
 52       this.$emit("update:showMapDialog", false);
 53     },
 54     getBounds(
 55       nodes,
 56       defineKey = {
 57         x: "lng",
 58         y: "lat"
 59       }
 60     ) {
 61       let min_x, min_y, max_x, max_y;
 62       nodes.forEach(node => {
 63         min_x = min_x ? min_x : node[defineKey.x];
 64         min_x = min_x < node[defineKey.x] ? min_x : node[defineKey.x];
 65         min_y = min_y ? min_y : node[defineKey.y];
 66         min_y = min_y < node[defineKey.y] ? min_y : node[defineKey.y];
 67         max_x = max_x ? max_x : node[defineKey.x];
 68         max_x = max_x > node[defineKey.x] ? max_x : node[defineKey.x];
 69         max_y = max_y ? max_y : node[defineKey.y];
 70         max_y = max_y > node[defineKey.y] ? max_y : node[defineKey.y];
 71       });
 72       let offset_x = max_x - min_x;
 73       min_x = min_x - offset_x;
 74       max_x = max_x + offset_x;
 75       let offset_y = max_y - min_y;
 76       min_y = min_y - offset_y;
 77       max_y = max_y + offset_y;
 78 
 79       return [
 80         [min_x, min_y],
 81         [max_x, max_y]
 82       ];
 83     },
 84     // 删除聚合图层
 85     removeClusterMarkerLayer() {
 86       if (this.clusterMarkerLayer) {
 87         this.clusterMarkerLayer.destroy();
 88         this.scene.removeMarkerLayer(this.clusterMarkerLayer);
 89       }
 90     },
 91     initMap() {
 92       this.scene = new Scene({
 93         id: "map",
 94         logoVisible: false, // 关闭L7的logo
 95         map: new GaodeMap({
 96           style: "dark",
 97           center: [118.788336, 32.022806],
 98           pitch: 0,
 99           zoom: 12,
100           token: "c6f04d87fd44069967d71742e2507919"
101         })
102       });
103       // 加载的AMap会挂载在全局的window对象上
104       this.scene.on("loaded", () => {
105         window.AMap.plugin(["AMap.ToolBar"], () => {
106           this.scene.map.addControl(new AMap.ToolBar());
107         });
108         // 添加 Marker 统一管理图层
109         if (this.clusterMarkerLayer) {
110           this.removeClusterMarkerLayer();
111         }
112         this.clusterMarkerLayer = new MarkerLayer();
113         for (let i = 0; i < this.coordinateList.length; i++) {
114           const el = document.createElement("label");
115           let popup = new Popup({
116             anchor: "top"
117           })
118             .setText(this.coordinateList[i].name)
119             .setLngLat({
120               lng: this.coordinateList[i].lng,
121               lat: this.coordinateList[i].lat
122             });
123           el.className = "labelclass";
124           el.style.background = `url(${locationImg}) no-repeat`;
125           el.style.width = `30px`;
126           el.style.height = `30px`;
127           el.style.backgroundSize = "100%";
128           const marker = new Marker({
129             element: el
130           })
131             .setLnglat({
132               lng: this.coordinateList[i].lng,
133               lat: this.coordinateList[i].lat
134             })
135             .setPopup(popup);
136           this.clusterMarkerLayer.addMarker(marker);
137         }
138         this.scene.addMarkerLayer(this.clusterMarkerLayer);
139         let bounds = this.getBounds(this.coordinateList);
140         this.scene.fitBounds(bounds);
141       });
142     }
143   }
144 };
145 </script>
146 
147 <style scoped lang="scss">
148 #map {
149   position: relative;
150   height: 600px;
151 }
152 </style>

 

标签:node,min,灯杆,scene,clusterMarkerLayer,空间数据,L7,max,defineKey
From: https://www.cnblogs.com/guwufeiyang/p/18129458

相关文章

  • rhel7和centos7以上版本忘记root密码处理方法
    目录1.开机进入grub菜单2.找到linux16一行进行配置3.挂载文件系统并重置密码1.开机进入grub菜单进入grub菜单,选择默认第一个启动项,按e进行编辑2.找到linux16一行进行配置找到linux16一行,摁ctrl+e跳转到行尾,输入\rd.break,再按ctrl+x进入急救模式3.挂载文件系统并重......
  • 【英伟达】GTC 2024|黄仁勋2小时演讲精华版|六大亮点| Blackwell GPU | DGX B200 | NV
    视频地址:https://www.youtube.com/watch?v=zBIddyiMXsU......
  • 智慧路灯杆如何提升智慧城市文旅形象
    今年以来,全国多地城市凭借本地独特物产、独特旅游环境等亮点火爆出圈,为城市带来显著经济增长和形象提升。文旅经济作为高附加值产业,具有高收益、高潜力等特点,还有助于推动城市经济转型和可持续发展。  推动城市文旅经济发展,离不开对城市文旅形象的建设和塑造。由于路灯杆具......
  • 智慧路灯杆AI监测应用,让高速出行更安全
    高速公路是现代交通出行的重要组成,高速公路上的交通安全也一直是人们关注的焦点。针对更好监测和管理高速公路上的交通状况,可以基于智慧路灯杆打造AI交通监测应用,通过智能感知高速路段的路况、车况、环境状况,实现实时风险感知、风险预警和协同处置,让高速出行更安全。  方案......
  • 点亮城市名片丨计讯物联智慧灯杆系统在通讯基地的成功应用
    项目背景在国家新型城镇化大背景下,十四五规划纲要强调“加快数字化发展,建设数字中国”,明确提出“以数字化助推城乡发展和治理模式创新”,全面提高城市的运行效率和宜居程度。  项目概况为满足灯杆灯光亮度的远程智能管理、对灯杆周遭的数据信息的采集、平台人员的信息发布......
  • 点亮城市名片丨计讯物联智慧灯杆系统在通讯基地的成功应用
    项目背景在国家新型城镇化大背景下,十四五规划纲要强调“加快数字化发展,建设数字中国”,明确提出“以数字化助推城乡发展和治理模式创新”,全面提高城市的运行效率和宜居程度。  项目概况为满足灯杆灯光亮度的远程智能管理、对灯杆周遭的数据信息的采集、平台人员的信息发布......
  • Xshell7、Xftp7安装破解版教程(亲测可用)
    Xftp7和Xshell7是大家常用的终端工具,让您在访问终端的同时能进行多窗口传输、编辑文件,提高工作效率。下载安装包链接:https://pan.baidu.com/s/1pr-AectkEKEvz0cF0vfi_w?pwd=08aq提取码:08aq软件安装双击下载好的安装包,打开安装向导,选择“下一步”。  请您仔细阅......
  • Python SciPy 空间数据
    SciPy空间数据https://blog.csdn.net/weixin_64338372/article/details/128675235?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170381772916800222899723%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=170381772916800222899......
  • 新一代RL78微控制器,R7F100GPJ2DFA和R7F100GPJ3CFA低功耗MCU、32MHz
    概览RL78/G23低功耗MCU可在41μA/MHzCPU运行频率下工作,功耗低,停止4KBSRAM保持时为210nA。该MCU设有snooze模式排序器,可显著降低间歇工作时的功耗。RL78/G23组具有1.6V至5.5V宽工作电压范围,频率高达32MHz。它们还具有30引脚至128引脚各种封装引脚数和高达768KB闪存。除了增强的模......
  • 智慧路灯杆如何实现雪天道路安全监测
    随着北方区域连续发生暴雪、寒潮、大风等气象变化,北方多地产生暴雪和低温雨雪冰冻灾害风险,冬季雨雪天气深度影响人们出行生活,也持续增加道路交通风险。 智慧路灯杆是现代城市不可或缺的智能基础设施,凭借搭载智慧照明、环境监测、智能监控、信息屏、广播、充电桩等设备,发挥着多......