提交 35feb2ce 编写于 作者: KK's avatar KK

地图逻辑调整

上级 148cc27b
......@@ -55,14 +55,6 @@ import { Http } from "@/ibiz-core/utils";
*/
public items:Array<any> =[];
/**
* map数据
*
* @param {Array<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public geoCoordMap:any = [];
/**
* 获取单项树
*
......@@ -143,9 +135,10 @@ import { Http } from "@/ibiz-core/utils";
this.$emit('load', (response.data && response.data) ? response.data : []);
this.items = [];
this.items = response.data;
this.series.forEach((temp:any) => {
temp.data = this.convertDat(temp.name);
});
for (let index = 0; index < this.series.length; index++) {
const element:any = this.series[index];
element.data = await this.convertDat(element.name);
}
this.setOptions();
return response;
}
......@@ -310,9 +303,6 @@ import { Http } from "@/ibiz-core/utils";
Object.assign(this.option, { tooltip: this.tooltip }, { visualMap: this.visualMap }, { geo: this.geo }, { series: this.series })
let element: any = document.getElementById(this.mapId);
this.map = echarts.init(element);
this.loadCityList().then((res:any)=>{
this.geoCoordMap = res;
});
}
// 绘制
......@@ -324,53 +314,37 @@ import { Http } from "@/ibiz-core/utils";
this.map.setOption(this.option);
}
/**
* 获取城市坐标
*
* @memberof AppCustomize
*/
public loadCityList(): Promise<any> {
return new Promise((resolve: any, reject: any) => {
Http.getInstance()
.get("./assets/json/city.json")
.then((response: any) => {
if (response && response.status === 200 && response.data) {
let result: Array<any> = [];
if (typeof response.data == "string") {
const index: number = response.data.lastIndexOf(",");
result = JSON.parse(response.data);
} else {
result = response.data;
}
resolve(result);
}
})
.catch((response: any) => {
});
});
}
// 定位数据位置
public convertDat (tag:any) {
if( !this.geoCoordMap){
return []
}
let res:any = []
let mapItemModel = this.mapItems[tag];
let mapItemData :any= this.items[tag];
mapItemData.forEach((item:any) => {
let latitude = item[mapItemModel.latitude];
let longitude = item[mapItemModel.longitude];
let geoCoord:number = this.geoCoordMap.findIndex((temp:any)=>{return temp.latitude == latitude && temp.longitude == longitude});
if (geoCoord > -1) {
for (let index = 0; index < mapItemData.length; index++) {
const element = mapItemData[index];
let latitude = element[mapItemModel.latitude];
let longitude = element[mapItemModel.longitude];
if(longitude && latitude){
let cityName = await this.getCityName(`${longitude},${latitude}`);
res.push({
name: this.geoCoordMap[geoCoord].name,
name: cityName,
value: [longitude,latitude].concat(mapItemData.filter((temp:any)=>{return temp[mapItemModel.latitude] == latitude && temp[mapItemModel.longitude]==longitude }).length,mapItemModel.code)
});
}
});
}
return res;
}
/**
* 获取城市坐标
*/
public async getCityName(location:string) {
let cityInfo = await Http.getInstance().get("api/v3/geocode/regeo",{key:"f24180cec13fe7e72472dcb9fcd26c0e",location:location})
if (cityInfo && cityInfo.status === 200 && cityInfo.data) {
if(cityInfo.data.infocode == 10000 && cityInfo.data.regeocode && cityInfo.data.regeocode.addressComponent){
return cityInfo.data.regeocode.addressComponent.city.length != 0?cityInfo.data.regeocode.addressComponent.city:cityInfo.data.regeocode.addressComponent.province;
}
}
}
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册