import calculate from '@/utils/map/calculate';
|
import gridMapUtil from '@/utils/map/grid';
|
import { map } from '@/utils/map/index_old';
|
|
function clearAll(mapViews) {
|
if (mapViews) {
|
if (typeof mapViews.textViews === 'object') {
|
map.remove(mapViews.textViews);
|
}
|
if (typeof mapViews.gridViews === 'object') {
|
map.remove(mapViews.gridViews);
|
}
|
}
|
}
|
|
function clearText(mapViews) {
|
if (mapViews && typeof mapViews.textViews === 'object') {
|
map.remove(mapViews.textViews);
|
}
|
}
|
|
// 绘制网格线
|
function drawPolyline(gridInfo) {
|
// 绘制网格
|
const points = gridInfo.map((v) => {
|
return calculate.wgs84_To_Gcj02(v.longitude, v.latitude);
|
});
|
const gridPoints = gridMapUtil.parseGridPoint(points);
|
const gridViews = gridMapUtil.drawPolylines(gridPoints);
|
return { gridViews, gridPoints, points };
|
}
|
|
// 绘制监测数据值
|
function drawDataText(points, gridData, textViews, labelsLayer) {
|
const data = gridData.map((v, i) => {
|
return {
|
lnglat_GD: points[i],
|
data: v.pm25 ? (v.pm25 + 'μg/m³') : ''
|
};
|
});
|
return gridMapUtil.drawGridTextLabel(data, textViews, labelsLayer, 'bottom');
|
}
|
|
// 绘制监测数据排名文本
|
function drawRankText(points, gridData, textViews, labelsLayer) {
|
const data = gridData.map((v, i) => {
|
return {
|
lnglat_GD: points[i],
|
data: v.pm25 ? ('排名: ' + v.rank) : ''
|
};
|
});
|
return gridMapUtil.drawGridTextLabel(data, textViews, labelsLayer, 'top');
|
}
|
|
// 绘制监测数据值对应网格颜色
|
function drawColor(gridViews, gridData) {
|
const pm25Data = gridData.map((v) => {
|
return v.pm25;
|
});
|
gridMapUtil.drawGridColor(gridViews, pm25Data, 'PM25');
|
}
|
|
export default {
|
drawPolyline,
|
drawDataText,
|
drawRankText,
|
drawColor,
|
clearText,
|
clearAll
|
};
|