Commit 1a5069d3 authored by 范加坤's avatar 范加坤

Merge remote-tracking branch 'origin/lc_branch' into van_branch

parents f5b5ac39 7b9d5825
...@@ -58,7 +58,6 @@ export default { ...@@ -58,7 +58,6 @@ export default {
// 扩大echarts点击面的大小,即点击灰色面也可以触发 // 扩大echarts点击面的大小,即点击灰色面也可以触发
that.chart.getZr().on("click", function (params) { that.chart.getZr().on("click", function (params) {
console.log(params)
const pointInPixel = [params.offsetX, params.offsetY]; const pointInPixel = [params.offsetX, params.offsetY];
if (that.chart.containPixel("grid", pointInPixel)) { if (that.chart.containPixel("grid", pointInPixel)) {
/*此处添加具体执行代码*/ /*此处添加具体执行代码*/
...@@ -66,19 +65,17 @@ export default { ...@@ -66,19 +65,17 @@ export default {
{ seriesIndex: 0 }, { seriesIndex: 0 },
pointInPixel pointInPixel
); );
//X轴序号
console.log(pointInGrid)
const xIndex = pointInGrid[1];
//获取当前图表的option //获取当前图表的option
const op = that.chart.getOption(); const op = that.chart.getOption();
let name = ""; let name = "";
//获得图表中我们想要的数据 判断数据在x轴还是y轴 //获得图表中我们想要的数据 判断数据在x轴还是y轴
// console.log(op.xAxis, xIndex);
if (op.xAxis[0].type === "category") { if (op.xAxis[0].type === "category") {
name = op.xAxis[0].data[xIndex]; // x轴为数据,选择pointInGrid第零位
name = op.xAxis[0].data[pointInGrid[0]];
} else { } else {
console.log(xIndex) name = op.yAxis[0].data[pointInGrid[1]];
name = op.yAxis[0].data[xIndex];
} }
that.$emit("barClick", { name, data: params }); that.$emit("barClick", { name, data: params });
......
...@@ -3,32 +3,32 @@ ...@@ -3,32 +3,32 @@
</template> </template>
<script> <script>
import mapboxgl from 'mapbox-gl' import mapboxgl from "mapbox-gl";
import { register } from './config/map.js' import { register } from "./config/map.js";
import style from './config/index.js' import style from "./config/index.js";
export default { export default {
props: { props: {
center: { center: {
type: Array, type: Array,
default: () => [110, 30] default: () => [110, 30],
}, },
zoom: { zoom: {
type: Number, type: Number,
default: 2 default: 2,
}, },
mapId: { mapId: {
// 接收图层容器的ID // 接收图层容器的ID
type: String || undefined, type: String || undefined,
default: 'map' default: "map",
} },
}, },
data() { data() {
return { return {
map: null map: null,
} };
}, },
mounted() { mounted() {
this.initMap() this.initMap();
}, },
methods: { methods: {
initMap() { initMap() {
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
zoom: 3, zoom: 3,
sources: {}, sources: {},
layers: [], layers: [],
glyphs: './fonts/{fontstack}/{range}.pbf' glyphs: "./fonts/{fontstack}/{range}.pbf",
}, },
maxZoom: 19.9, maxZoom: 19.9,
minZoom: 0.1, minZoom: 0.1,
...@@ -51,75 +51,75 @@ export default { ...@@ -51,75 +51,75 @@ export default {
trackResize: true, trackResize: true,
attributionControl: false, attributionControl: false,
preserveDrawingBuffer: true, preserveDrawingBuffer: true,
renderWorldCopies: false // 地图不重复 renderWorldCopies: false, // 地图不重复
// style // style
}) });
this.map.on('load', async () => { this.map.on("load", async () => {
let map = this.map let map = this.map;
window.map = this.map window.map = this.map;
// 添加新的地图实例方法, 初始化相关状态 // 添加新的地图实例方法, 初始化相关状态
register(mapboxgl.Map.prototype) register(mapboxgl.Map.prototype);
// map._initMapState({ map._initMapState({
// center: this.center, center: [110, 30],
// zoom: this.zoom zoom: this.zoom,
// }) });
// console.log() // console.log()
map.setBaseMap({ sources: style.sources, layers: style.layers }) map.setBaseMap({ sources: style.sources, layers: style.layers });
// 添加source // 添加source
Object.entries(style.sources).forEach(item => { Object.entries(style.sources).forEach((item) => {
map.addSource(item[0], item[1]) map.addSource(item[0], item[1]);
}) });
// 添加layers // 添加layers
style.layers.forEach(item => { style.layers.forEach((item) => {
map.addLayer(item) map.addLayer(item);
}) });
await this.addProvinceLayer() await this.addProvinceLayer();
this.$emit('onload', map) this.$emit("onload", map);
}) });
}, },
addProvinceLayer() { addProvinceLayer() {
// this.$api.data.getProvinceData().then(res => { // this.$api.data.getProvinceData().then(res => {
this.map.addSource('province', { this.map.addSource("province", {
tiles: [ tiles: [
'http://39.104.87.15/api/tileset/agnps_sjwj/{z}/{x}/{y}.vector.pbf' "http://39.104.87.15/api/tileset/agnps_sjwj/{z}/{x}/{y}.vector.pbf",
], ],
type: 'vector' type: "vector",
}) });
this.map.addLayer({ this.map.addLayer({
id: 'province', id: "province",
source: 'province', source: "province",
type: 'fill', type: "fill",
'source-layer': 'province', "source-layer": "province",
layout: {}, layout: {},
paint: { paint: {
'fill-outline-color': '#fff', "fill-outline-color": "#fff",
'fill-color': 'rgba(0, 0, 0, 0)' "fill-color": "rgba(0, 0, 0, 0)",
} },
}) });
this.map.addLayer({ this.map.addLayer({
id: '__province_title', id: "__province_title",
type: 'symbol', type: "symbol",
source: 'area_title', source: "area_title",
'source-layer': 'province', "source-layer": "province",
layout: { layout: {
'text-font': ['open-sans'], "text-font": ["open-sans"],
'text-field': '{PXZQMC}', "text-field": "{PXZQMC}",
'text-size': 17, "text-size": 17,
'text-max-width': 5 "text-max-width": 5,
}, },
// maxzoom: 7, // maxzoom: 7,
// minzoom: 1, // minzoom: 1,
paint: { paint: {
'text-color': '#fff', "text-color": "#fff",
'text-halo-color': '#000', "text-halo-color": "#000",
'text-halo-width': 1 "text-halo-width": 1,
} },
}) });
} },
} },
} };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
export default{ // export default
province:[ const data = {
{ code:'10', name:'全国',}, province: [
{ code:'11', name:'北京',}, { code: "10", name: "全国" },
{ code:'12', name:'天津',}, { code: "11", name: "北京" },
{ code:'13', name:'河北',}, { code: "12", name: "天津" },
{ code:'14', name:'山西',}, { code: "13", name: "河北" },
{ code:'15', name:'内蒙',}, { code: "14", name: "山西" },
{ code:'21', name:'辽宁',}, { code: "15", name: "内蒙" },
{ code:'22', name:'吉林',}, { code: "21", name: "辽宁" },
{ code:'23', name:'黑龙江',}, { code: "22", name: "吉林" },
{ code:'31', name:'上海',}, { code: "23", name: "黑龙江" },
{ code:'32', name:'江苏',}, { code: "31", name: "上海" },
{ code:'33', name:'浙江',}, { code: "32", name: "江苏" },
{ code:'34', name:'安徽',}, { code: "33", name: "浙江" },
{ code:'35', name:'福建',}, { code: "34", name: "安徽" },
{ code:'36', name:'江西',}, { code: "35", name: "福建" },
{ code:'37', name:'山东',}, { code: "36", name: "江西" },
{ code:'41', name:'河南',}, { code: "37", name: "山东" },
{ code:'42', name:'湖北',}, { code: "41", name: "河南" },
{ code:'43', name:'湖南',}, { code: "42", name: "湖北" },
{ code:'44', name:'广东',}, { code: "43", name: "湖南" },
{ code:'45', name:'广西',}, { code: "44", name: "广东" },
{ code:'46', name:'海南',}, { code: "45", name: "广西" },
{ code:'50', name:'重庆',}, { code: "46", name: "海南" },
{ code:'51', name:'四川',}, { code: "50", name: "重庆" },
{ code:'52', name:'贵州',}, { code: "51", name: "四川" },
{ code:'53', name:'云南',}, { code: "52", name: "贵州" },
{ code:'54', name:'西藏',}, { code: "53", name: "云南" },
{ code:'61', name:'陕西',}, { code: "54", name: "西藏" },
{ code:'62', name:'甘肃',}, { code: "61", name: "陕西" },
{ code:'63', name:'青海',}, { code: "62", name: "甘肃" },
{ code:'64', name:'宁夏',}, { code: "63", name: "青海" },
{ code:'65', name:'新疆',}, { code: "64", name: "宁夏" },
] { code: "65", name: "新疆" },
} ],
\ No newline at end of file };
export default data;
export function getCodeOfName(name) {
const obj = data.province.find((item) => item.name === name);
console.log(obj);
if (!obj) return null;
return obj.code;
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import Map from "@/components/Map/Map.vue"; import Map from "@/components/Map/Map.vue";
import { BiomassData } from "../config/biomass.config.js"; import { BiomassData } from "../config/biomass.config.js";
import { color, colorLabel } from "../config/legend.config"; import { color, colorLabel } from "../config/legend.config";
import { mapGetters } from "vuex";
export default { export default {
name: "biogasManure", name: "biogasManure",
props: { props: {
...@@ -19,6 +20,10 @@ export default { ...@@ -19,6 +20,10 @@ export default {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
provinceCode: {
type: String,
default: "",
},
}, },
data() { data() {
return { return {
...@@ -41,6 +46,7 @@ export default { ...@@ -41,6 +46,7 @@ export default {
filterCon.push("#f00"); filterCon.push("#f00");
return filterCon; return filterCon;
}, },
...mapGetters(["getMsgOfProvince"]),
}, },
methods: { methods: {
onload(map) { onload(map) {
...@@ -71,6 +77,18 @@ export default { ...@@ -71,6 +77,18 @@ export default {
); );
} }
}, },
setProvinceView() {
if (this.provinceCode) {
const detail = this.getMsgOfProvince(this.provinceCode);
if (this.map && detail) {
this.map.fitBounds(detail.bbox, {
padding: { top: 50, bottom: 200, left: 50, right: 200 },
});
}
} else {
this.map.recover();
}
},
}, },
watch: { watch: {
type() { type() {
...@@ -79,6 +97,9 @@ export default { ...@@ -79,6 +97,9 @@ export default {
data() { data() {
this.setPaintColor(); this.setPaintColor();
}, },
provinceCode() {
this.setProvinceView();
},
}, },
}; };
</script> </script>
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
:style="{ width: `${getItemOfType.length === 1 ? '100%' : '48%'}` }" :style="{ width: `${getItemOfType.length === 1 ? '100%' : '48%'}` }"
> >
<div class="partItem"> <div class="partItem">
<Echart ref="echart3" :options="setOptionOfEchart(item.key)"></Echart> <Echart
ref="echart3"
:options="setOptionOfEchart(item.key)"
@barClick="barClick"
></Echart>
</div> </div>
</PartWrap> </PartWrap>
</div> </div>
...@@ -43,12 +47,7 @@ export default { ...@@ -43,12 +47,7 @@ export default {
}, },
getValOfdata() { getValOfdata() {
const keys = this.getItemOfType; const keys = this.getItemOfType;
const res = { const res = {};
// gn_local: [],
// ghcx_local: [],
// rj_local: [],
// th_local: [],
};
keys.forEach((item) => { keys.forEach((item) => {
res[item.key] = []; res[item.key] = [];
...@@ -61,10 +60,6 @@ export default { ...@@ -61,10 +60,6 @@ export default {
yAxis: item.properties[i[0]], yAxis: item.properties[i[0]],
}); });
}); });
// res.gn_local.push({ xAxis: pname, yAxis: gn_local });
// res.ghcx_local.push({ xAxis: pname, yAxis: ghcx_local });
// res.rj_local.push({ xAxis: pname, yAxis: rj_local });
// res.th_local.push({ xAxis: pname, yAxis: th_local });
}); });
return res; return res;
}, },
...@@ -158,6 +153,9 @@ export default { ...@@ -158,6 +153,9 @@ export default {
this.getValOfdata; this.getValOfdata;
}); });
}, },
barClick(name) {
this.$emit("barClick", name);
},
}, },
}; };
</script> </script>
......
<template> <template>
<div class="BiomassEnergyWarm"> <div class="BiomassEnergyWarm">
<LeftPart :type="statusValue.key"></LeftPart> <LeftPart :type="statusValue.key"></LeftPart>
<BiogasManureMap :type="statusValue.key" :data="data"></BiogasManureMap> <BiogasManureMap
:type="statusValue.key"
:data="data"
:provinceCode="provinceCode"
></BiogasManureMap>
<StatusControl <StatusControl
:statusStyle="{ position: 'absolute', right: '600px', top: '100px' }" :statusStyle="{ position: 'absolute', right: '600px', top: '100px' }"
:list="statusControlList" :list="statusControlList"
v-model="statusValue" v-model="statusValue"
></StatusControl> ></StatusControl>
<SortList :type="statusValue.key"></SortList> <SortList :type="statusValue.key" @barClick="barClick"></SortList>
<!-- 表格数据展示 --> <!-- 表格数据展示 -->
<Table :type="statusValue.key" :data="data"></Table> <Table :type="statusValue.key" :data="data"></Table>
<!-- 底部总数 --> <!-- 底部总数 -->
...@@ -17,6 +21,7 @@ ...@@ -17,6 +21,7 @@
<Echart <Echart
ref="echart3" ref="echart3"
:options="setOptionOfEchart(getItemOfType.key)" :options="setOptionOfEchart(getItemOfType.key)"
@barClick="barClick"
></Echart> ></Echart>
</div> </div>
</PartWrap> </PartWrap>
...@@ -29,17 +34,15 @@ ...@@ -29,17 +34,15 @@
import PartWrap from "@/components/PartWrap/PartWrap.vue"; import PartWrap from "@/components/PartWrap/PartWrap.vue";
import Echart from "@/components/Echart/Echarts.vue"; import Echart from "@/components/Echart/Echarts.vue";
import BiogasManureMap from "./components/biogasManureMap.vue"; import BiogasManureMap from "./components/biogasManureMap.vue";
// import DateWidget from "@/components/DateWidget/DateWidget.vue";
// // import PartInfo from '../../components/PartInfo/PartInfo.vue'
// import Echart from "@/components/Echart/Echarts.vue";
// import PartWrap from "@/components/PartWrap/PartWrap.vue";
import StatusControl from "@/components/statusControl/index.vue"; import StatusControl from "@/components/statusControl/index.vue";
import Legend from "@/components/Lengend/Lengend.vue"; import Legend from "@/components/Lengend/Lengend.vue";
import { getCodeOfName } from "@/config/city.config";
import LeftPart from "./components/leftPart.vue"; import LeftPart from "./components/leftPart.vue";
import SortList from "./components/sortList.vue"; import SortList from "./components/sortList.vue";
import Table from "./components/table.vue"; import Table from "./components/table.vue";
import { BiomassData } from "./config/biomass.config.js"; import { BiomassData } from "./config/biomass.config.js";
import { color, colorLabel } from "./config/legend.config"; import { color, colorLabel } from "./config/legend.config";
import { mapGetters } from "vuex";
export default { export default {
name: "BiomassEnergyWarm", name: "BiomassEnergyWarm",
data() { data() {
...@@ -55,6 +58,7 @@ export default { ...@@ -55,6 +58,7 @@ export default {
data: [], data: [],
color, color,
colorLabel, colorLabel,
provinceCode: "",
}; };
}, },
components: { components: {
...@@ -161,9 +165,11 @@ export default { ...@@ -161,9 +165,11 @@ export default {
return option; return option;
}; };
}, },
...mapGetters(["getMsgOfProvince"]),
}, },
created() { created() {
this.getEnergyWarm(); this.getEnergyWarm();
console.log(this.getMsgOfProvince("14"));
}, },
methods: { methods: {
getEnergyWarm() { getEnergyWarm() {
...@@ -175,6 +181,11 @@ export default { ...@@ -175,6 +181,11 @@ export default {
this.getValOfdata; this.getValOfdata;
}); });
}, },
barClick(name) {
console.log(name);
const code = getCodeOfName(name.name);
code && (this.provinceCode = code);
},
}, },
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment