From da21fe61c8d8d22ca1b6244b233fbce9e2dc5814 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 27 十月 2023 09:16:35 +0800
Subject: [PATCH] 统计页面
---
src/components/map/leafletMap.vue | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/components/map/leafletMap.vue b/src/components/map/leafletMap.vue
index b75ffa7..96e2b42 100644
--- a/src/components/map/leafletMap.vue
+++ b/src/components/map/leafletMap.vue
@@ -9,6 +9,7 @@
data() {
return {
map: null,
+ marker: null,
map_point: { x: "119.27179890", y: "28.59027084" },
map_zoom: 15,
mapUrl:
@@ -42,7 +43,7 @@
};
},
mounted() {
- console.log('/* 鍒涘缓鍦板浘瀹炰緥 */')
+ console.log("/* 鍒涘缓鍦板浘瀹炰緥 */");
setTimeout(() => {
this.createrMap();
}, 100);
@@ -50,7 +51,6 @@
methods: {
/* 鍒涘缓鍦板浘瀹炰緥 */
createrMap() {
-
this.option.center = [eval(this.map_point.y), eval(this.map_point.x)];
this.option.zoom = this.map_zoom;
this.map = this.$map.createrMap("map-container", this.option);
@@ -71,18 +71,24 @@
// // // });
// });
this.locationMap();
-
},
locationMap() {
- if (this.mark && this.map) {
- // 鍒涘缓涓�涓� Marker 瀹炰緥锛�
- var marker = L.marker([eval(this.map_point.y), eval(this.map_point.x)]).addTo(
- this.map
+ if (this.map_point && this.map_point.y) {
+ this.map.setView(
+ [eval(this.map_point.y), eval(this.map_point.x)],
+ this.map_zoom
);
- let that = this
+ }
+ if (this.mark && this.map) {
+ if (this.marker) this.map.removeLayer(this.marker);
+ // 鍒涘缓涓�涓� Marker 瀹炰緥锛�
+ this.marker = L.marker([
+ eval(this.map_point.y),
+ eval(this.map_point.x),
+ ]).addTo(this.map);
+ let that = this;
// 灏嗗垱寤虹殑鐐规爣璁版坊鍔犲埌宸叉湁鐨勫湴鍥惧疄渚嬶細
- marker.on("click", function (e) {
- console.log("666");
+ this.marker.on("click", function (e) {
that.$emit("fatherMethod");
});
}
--
Gitblit v1.8.0