From 1a9cfa3d9e9946dc4a576cf47d98489017c5f289 Mon Sep 17 00:00:00 2001
From: 1012414140@qq.com <1012414140@qq.com>
Date: 星期五, 26 十二月 2025 14:15:00 +0800
Subject: [PATCH] feat: 地图上鼠标触摸添加车位数等信息
---
src/components/page/leaderShow/leaderIndex.vue | 76 +++++++++++++++++++++++++++++++++++---
1 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/src/components/page/leaderShow/leaderIndex.vue b/src/components/page/leaderShow/leaderIndex.vue
index a16f264..7e21332 100644
--- a/src/components/page/leaderShow/leaderIndex.vue
+++ b/src/components/page/leaderShow/leaderIndex.vue
@@ -233,6 +233,7 @@
getLogoUrl: this.$systemconfig.basePath + '/statistic/getLogo',
findAllUrl: this.$systemconfig.basePath + '/ffzf/user/findAll',
illegalCarUrl: this.$systemconfig.basePath + '/ffzf/notice/illegalCar2',
+ getCarNumUrl: this.$systemconfig.basePath + '/ffzf/park/getCarNum'
},
weizhangTimer:null, //杩濈珷list瀹氭椂鍣�
getDataTimer:null, //缁熻鏁版嵁瀹氭椂鍣�
@@ -290,6 +291,8 @@
map:'',
centerLng:'114.225914',
centerLat:'36.438982',
+ pointNum1: '',
+ pointNum2: '',
}
},
mounted() {
@@ -451,12 +454,73 @@
this.map = map;
// let goodsData = require('../../../assets/custom_map_config.json')
// 璁惧畾鍦板浘鐨勪腑蹇冪偣鍜屽潗鏍�
- let point = new BMap.Point(this.centerLng, this.centerLat);
- let marker = new BMap.Marker(point) // 鍒涘缓鏍囨敞
- // 璁剧疆涓績鐐瑰潗鏍囧拰鍦板浘绾у埆
- this.map.centerAndZoom(point, 1);
- // 娣诲姞鑷畾涔夎鐩栫墿
- this.map.addOverlay(marker) // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+ // let point = new BMap.Point(this.centerLng, this.centerLat);
+ // let marker = new BMap.Marker(point) // 鍒涘缓鏍囨敞
+ // // 璁剧疆涓績鐐瑰潗鏍囧拰鍦板浘绾у埆
+ // this.map.centerAndZoom(point, 1);
+ // // 娣诲姞鑷畾涔夎鐩栫墿
+ // this.map.addOverlay(marker) // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+
+
+ const centerPoint = new BMap.Point(114.23123, 36.43123);
+ // 瀹氫箟澶氱偣鍧愭爣
+ const points = [
+ {lng: 114.23123, lat: 36.43123, name: '鏂颁笘绾仠杞﹀満', id: 4 },
+ {lng: 114.18, lat: 36.44, name: '鍏噷鏂瑰仠杞﹀満', id: 36 },
+ {lng: 114.21, lat: 36.43, name: '婊忔簮鍫ゅ仠杞﹀満', id: 34 },
+ {lng: 114.24, lat: 36.42, name: '婊忛槼婀垮湴鍏洯鍋滆溅鍦�', id: 33 },
+ {lng: 114.18, lat: 36.43, name: '闄剁摲鍗氱墿棣嗗仠杞﹀満', id: 30 },
+ {lng: 114.21, lat: 36.42, name: '椋庢湀鍏冲仠杞﹀満', id: 25 },
+ {lng: 114.23, lat: 36.44, name: '娓呮硥鍏洯鍋滆溅鍦�', id: 22 },
+ {lng: 114.21222, lat: 36.43111, name: '宄板嘲瀹鹃鍋滆溅鍦�', id: 7 },
+ {lng: 114.23, lat: 36.42, name: '鍗楀ご鏉戝仠杞﹀満', id: 20 },
+ {lng: 114.24125, lat: 36.43127, name: '鍥藉湡灞�鍋滆溅鍦�', id: 21 },
+ {lng: 114.22127, lat: 36.43129, name: '浜烘皯骞垮満鍦颁笅鍋滆溅鍦�', id: 8 },
+ ];
+ // 娣诲姞涓績鐐规爣璁�
+ const centerMarker = new BMap.Marker(centerPoint);
+ this.map.addOverlay(centerMarker);
+ // 寰幆娣诲姞鍏朵粬鐐�
+ points.forEach(coord => {
+ const point = new BMap.Point(coord.lng, coord.lat);
+ const marker = new BMap.Marker(point);
+ this.map.addOverlay(marker);
+
+ // 娣诲姞榧犳爣鎮仠浜嬩欢
+ marker.addEventListener("mouseover", (e) => {
+ this.$byutil.postData4(this, this.pageConfig.getCarNumUrl, { parkId: coord.id }, res => {
+ this.pointNum1 = res.data.num // 杞︿綅鎬绘暟
+ this.pointNum2 = Math.floor(Number(res.data.num) - Number(res.data.carNum));
+
+ // 鍒涘缓淇℃伅绐楀彛鍐呭
+ const content = `
+ <div style="padding:10px">
+ <h4>${coord.name}</h4>
+ <p>杞︿綅鎬绘暟: ${this.pointNum1}</p>
+ <p>鍓╀綑:${this.pointNum2} </p>
+ </div>
+ `;
+ // 鍒涘缓淇℃伅绐楀彛
+ const infoWindow = new BMap.InfoWindow(content, {
+ width: 200,
+ title: "璇︾粏淇℃伅"
+ });
+
+ // 鍦ㄦ爣璁扮偣浣嶇疆鎵撳紑淇℃伅绐楀彛
+ marker.openInfoWindow(infoWindow, point);
+ })
+ });
+ });
+ // 鍦板浘璁剧疆...
+ this.map.centerAndZoom(centerPoint, 1);
+ this.map.enableScrollWheelZoom(true);
+ this.map.setZoom(15);
+ // 鑷姩璋冩暣瑙嗛噹
+ const bounds = new BMap.Bounds();
+ [centerPoint, ...points].forEach(p => bounds.extend(p));
+ this.map.setViewport(bounds.getSouthWest(), bounds.getNorthEast());
+
+
// 鍏佽婊氳疆缂╂斁
this.map.enableScrollWheelZoom(point, 15);
// 璁剧疆鍦板浘榛樿缂╂斁姣斾緥
--
Gitblit v1.9.1