| | |
| | | data() { |
| | | return { |
| | | map: null, |
| | | marker: null, |
| | | map_point: { x: "119.27179890", y: "28.59027084" }, |
| | | map_zoom: 15, |
| | | mapUrl: |
| | |
| | | }; |
| | | }, |
| | | mounted() { |
| | | console.log('/* 创建地图实例 */') |
| | | console.log("/* 创建地图实例 */"); |
| | | setTimeout(() => { |
| | | this.createrMap(); |
| | | }, 100); |
| | |
| | | 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); |
| | |
| | | // // // }); |
| | | // }); |
| | | this.locationMap(); |
| | | |
| | | }, |
| | | locationMap() { |
| | | debugger |
| | | if (this.map_point && this.map_point.y) { |
| | | this.map.setView([eval(this.map_point.y), eval(this.map_point.x)], this.map_zoom); |
| | | |
| | | this.map.setView( |
| | | [eval(this.map_point.y), eval(this.map_point.x)], |
| | | this.map_zoom |
| | | ); |
| | | } |
| | | if (this.mark && this.map) { |
| | | if (this.marker) this.map.removeLayer(this.marker); |
| | | // 创建一个 Marker 实例: |
| | | var marker = L.marker([eval(this.map_point.y), eval(this.map_point.x)]).addTo( |
| | | this.map |
| | | ); |
| | | let that = this |
| | | 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) { |
| | | this.marker.on("click", function (e) { |
| | | that.$emit("fatherMethod"); |
| | | }); |
| | | } |