zhanghua
2025-04-14 829f5116884f98643ffc5b2a548a600d40c0cedb
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");
        });
      }