main
许宏杰 9 months ago
parent 3ee2ab10ca
commit d0b61a9c95

@ -8,3 +8,13 @@ export function getAreaData(query) {
params: query, params: query,
}); });
} }
//覆盖身份
export function getProvince(query) {
return request({
url: "/ykmap/line/searchCity",
method: "get",
params: query,
});
}

@ -15,10 +15,12 @@ import linePoint1 from "@/assets/images/linePoint1.png";
import linePoint2 from "@/assets/images/linePoint2.png"; import linePoint2 from "@/assets/images/linePoint2.png";
import MarsMap from "@/components/mars-map"; import MarsMap from "@/components/mars-map";
// import province from "@/assets/images/province.png"; // import province from "@/assets/images/province.png";
import { getProvince } from "@/api/yunkun/index.js";
export default { export default {
data() { data() {
const basePathUrl = window.basePathUrl || ""; const basePathUrl = window.basePathUrl || "";
return { return {
cityAttr: {},
options: { options: {
scene: { scene: {
center: { center: {
@ -80,7 +82,9 @@ export default {
initChina() { initChina() {
mars3d.Util.fetchJson({ url: this.chinaUrl }).then((res) => { mars3d.Util.fetchJson({ url: this.chinaUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res); const arr = mars3d.Util.geoJsonToGraphics(res);
arr.map((item, index) => { arr.map((item, index) => {
this.cityAttr[item.attr.name] = item.attr;
const polygonEntity = new mars3d.graphic.PolygonEntity({ const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: item.positions, positions: item.positions,
style: { style: {
@ -114,8 +118,8 @@ export default {
}); });
}, },
createEchartsLayer() { async createEchartsLayer() {
const options = this.getEchartsOption(); const options = await this.getEchartsOption();
const echartsLayer = new mars3d.layer.EchartsLayer(options); const echartsLayer = new mars3d.layer.EchartsLayer(options);
this.map.addLayer(echartsLayer); this.map.addLayer(echartsLayer);
// //
@ -124,68 +128,97 @@ export default {
}); });
}, },
getEchartsOption() { async getEchartsOption() {
const items = [ let res = await getProvince();
{
const items = res.data.map((item, index) => {
if (index == 0) {
item = {
level: 1, level: 1,
name: "江苏", name: item.city,
label: "jiangsu", label: item.city,
value: [118.767413, 32.041544], value: this.cityAttr[item.city].center,
symbol: "", symbol: "",
symbolSize: [30, 30], symbolSize: [30, 30],
}, };
{ } else {
level: 2, item = {
symbol: "",
name: "安徽",
label: "anhui",
category: 0,
active: true,
speed: 6,
value: [117.283042, 31.86119],
belong: "江苏",
},
{
level: 2,
symbol: "",
name: "浙江",
category: 0,
active: true,
speed: 6,
value: [120.153576, 30.287459],
belong: "江苏",
},
{
level: 2,
symbol: "",
name: "云南",
category: 0,
active: true,
speed: 6,
value: [102.712251, 25.040609],
belong: "江苏",
},
{
level: 2,
symbol: "",
name: "青海",
category: 0,
active: true,
speed: 6,
value: [101.778916, 36.623178],
belong: "江苏",
},
{
level: 2, level: 2,
symbol: "", symbol: "",
name: "内蒙古自治区", name: item.city,
label: item.city,
category: 0, category: 0,
active: true, active: true,
speed: 6, speed: 6,
value: [111.670801, 40.818311], value: this.cityAttr[item.city].center,
belong: "江苏", belong: res.data[0].city,
}, };
]; }
return item;
});
// const items = [
// {
// level: 1,
// name: "",
// label: "jiangsu",
// value: [118.767413, 32.041544],
// symbol: "",
// symbolSize: [30, 30],
// },
// {
// level: 2,
// symbol: "",
// name: "",
// label: "anhui",
// category: 0,
// active: true,
// speed: 6,
// value: [117.283042, 31.86119],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [120.153576, 30.287459],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [102.712251, 25.040609],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [101.778916, 36.623178],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [111.670801, 40.818311],
// belong: "",
// },
// ];
const lineColor = ["#fff", "#f6fb05", "#00fcff"]; const lineColor = ["#fff", "#f6fb05", "#00fcff"];
@ -205,6 +238,7 @@ export default {
if (el.belong) { if (el.belong) {
items.forEach((element) => { items.forEach((element) => {
if (el.belong === element.name) { if (el.belong === element.name) {
console.log(dataArr[el.level - 1]);
dataArr[el.level - 1].push([ dataArr[el.level - 1].push([
{ {
coord: element.value, coord: element.value,
@ -238,7 +272,7 @@ export default {
fontSize: 16, fontSize: 16,
color: "#fff", color: "#fff",
textBorderColor: "#2aa4e8", textBorderColor: "#2aa4e8",
offset: [0, 20], offset: [0, 10],
}, },
}, },
itemStyle: { itemStyle: {

Loading…
Cancel
Save