1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| export default { data() { return { mapChart: null, addressCode: [] }; }, mouted(){ this.mapChart = echarts.init(this.$refs["echarts-dom"]); this.getData(); }, methods: { getData("100000") { fetch(`${process.env.VUE_APP_ORIGIN}/geoData/${code}.json`) .then((res) => { return res.json(); }).then((res) => { this.addressCode = res.features; echarts.registerMap("echartsMap", res); this.setEchartsOptions(); }) .finally((err) => { this.mapLoading = false; }); }, setEchartsOptions() { this.mapChart.off("click"); this.mapChart.setOption({ series: [ { type: "map", mapType: "echartsMap", roam: true, scaleLimit: { min: 1.1, max: 5.2, }, data: this.addressCode, itemStyle: { normal: { borderWidth: 1.3, borderColor: "#00ffff", areaColor: "#09295b", }, emphasis: { show: true, borderWidth: 3, areaColor: "#0d559d", label: { show: true, textStyle: { color: "#fff", }, }, }, }, label: { show: true, textStyle: { color: "#fff", }, }, }, ], },true); this.addEchartsEventListener(); }, addEchartsEventListener() { const that = this; this.mapChart.on("click", function (params) { console.log(params.data); that.getData(params.data.codeNumber); });
this.mapChart.on("georoam", (params) => { that.$emit("swicthPanle", false); }); }, } }
|