云查询图片叠加到地图里bug修正
parent
63bc7eefbb
commit
101e97d189
|
|
@ -166,25 +166,12 @@
|
|||
};
|
||||
|
||||
// 定义预加载图片的方法
|
||||
const preloadImage = (url: string): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
resolve(url);
|
||||
};
|
||||
img.onerror = (error) => {
|
||||
reject(error);
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
};
|
||||
|
||||
const addOnMapChange = (value) => {
|
||||
setTimeout(async () => {
|
||||
let url = '';
|
||||
let fourpoint = '';
|
||||
if (value) {
|
||||
let data = {};
|
||||
let data: any = {};
|
||||
if (activeKey.value == '1') {
|
||||
props.data.forEach((item) => {
|
||||
if (item.name == '土地分类') {
|
||||
|
|
@ -208,7 +195,6 @@
|
|||
image.crossOrigin = 'anonymous';
|
||||
image.src = url;
|
||||
image.onload = () => {
|
||||
console.log(205, image);
|
||||
// 创建Canvas元素
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = image.width;
|
||||
|
|
@ -220,7 +206,6 @@
|
|||
ctx.drawImage(image, 0, 0, image.width, image.height);
|
||||
// 将Canvas内容转换为图片的数据URL
|
||||
const dataURL = canvas.toDataURL('image/jpeg');
|
||||
console.log(216, dataURL);
|
||||
|
||||
// 移除旧的图层和源
|
||||
if (map.getSource('radar')) {
|
||||
|
|
@ -228,25 +213,27 @@
|
|||
map.removeLayer('radar-layer');
|
||||
}
|
||||
|
||||
if(fourpoint[2][0] == fourpoint[3][0]){
|
||||
fourpoint[3][0] = fourpoint[0][0];
|
||||
}
|
||||
|
||||
// 添加新的源和图层
|
||||
map.addSource('radar', {
|
||||
type: 'image',
|
||||
url: dataURL,
|
||||
coordinates: fourpoint,
|
||||
// coordinates: [
|
||||
// [118.79657110932101, 35.1014168593995],
|
||||
// [118.79971349626699, 35.1014168593995],
|
||||
// [118.79971349626699, 35.0976945740112],
|
||||
// [118.79371349626699, 35.0976945740112],
|
||||
// ],
|
||||
paint: {
|
||||
'raster-opacity': 0,
|
||||
},
|
||||
});
|
||||
// console.log(fourpoint);
|
||||
|
||||
map.addLayer({
|
||||
id: 'radar-layer',
|
||||
type: 'raster',
|
||||
source: 'radar',
|
||||
paint: {
|
||||
'raster-fade-duration': 0,
|
||||
'raster-opacity': 0.5,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -260,6 +247,7 @@
|
|||
x = x / length;
|
||||
y = y / length;
|
||||
map.flyTo({
|
||||
// center: [118.79657110932101, 35.1014168593995],
|
||||
center: [fourpoint[0][0], fourpoint[0][1]],
|
||||
zoom: 14,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
const [registerTable] = useTable({
|
||||
api: CaseOffenceMinerals,
|
||||
columns: columns,
|
||||
title: '无人机全域巡查图斑情况统计表',
|
||||
// title: '无人机全域巡查图斑情况统计表',
|
||||
// titleHelpMessage: '合法、其他、非粮化、补办手续、拆除复耕均需市级审核通过才可判定为举证类型。',
|
||||
formConfig: {
|
||||
labelWidth: 120,
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@
|
|||
const [registerTable] = useTable({
|
||||
api: getCaseOffence,
|
||||
columns: columns,
|
||||
title: '无人机全域巡查图斑情况统计表',
|
||||
titleHelpMessage: '合法、其他、非粮化、补办手续、拆除复耕均需市级审核通过才可判定为举证类型。',
|
||||
// title: '无人机全域巡查图斑情况统计表',
|
||||
// titleHelpMessage: '合法、其他、非粮化、补办手续、拆除复耕均需市级审核通过才可判定为举证类型。',
|
||||
formConfig: {
|
||||
labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@
|
|||
const [registerTable] = useTable({
|
||||
api: getCaseOffence,
|
||||
columns: columns,
|
||||
title: '无人机全域巡查图斑情况统计表',
|
||||
titleHelpMessage: '合法、其他、非粮化、补办手续、拆除复耕均需市级审核通过才可判定为举证类型。',
|
||||
// title: '无人机全域巡查图斑情况统计表',
|
||||
// titleHelpMessage: '合法、其他、非粮化、补办手续、拆除复耕均需市级审核通过才可判定为举证类型。',
|
||||
formConfig: {
|
||||
labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@
|
|||
.catch((error) => {
|
||||
options.onError(error);
|
||||
});
|
||||
console.log(uploadFrom.value);
|
||||
}
|
||||
};
|
||||
// 步骤1-删除图层样式
|
||||
|
|
@ -304,7 +303,6 @@
|
|||
const sldContent = e.target.result;
|
||||
const styles = parseSLD(sldContent);
|
||||
assemblyPaint(styles);
|
||||
// uploadFrom.value.style = styles;
|
||||
};
|
||||
reader.onerror = (error) => {
|
||||
console.error('Error reading the file:', error);
|
||||
|
|
@ -318,9 +316,9 @@
|
|||
const namedLayers = xmlDoc.querySelectorAll('NamedLayer');
|
||||
const styles: any = [];
|
||||
|
||||
namedLayers.forEach((namedLayer) => {
|
||||
namedLayers?.forEach((namedLayer) => {
|
||||
const userStyles = namedLayer.querySelectorAll('UserStyle');
|
||||
userStyles.forEach((userStyle) => {
|
||||
userStyles?.forEach((userStyle) => {
|
||||
userStyle.children?.forEach((element) => {
|
||||
if (element && element.nodeName == 'se:FeatureTypeStyle') {
|
||||
element.children.forEach((featureTypeStyle) => {
|
||||
|
|
@ -428,7 +426,7 @@
|
|||
|
||||
// style
|
||||
uploadFrom.value.style = JSON.stringify(result);
|
||||
console.log(uploadFrom.value.style);
|
||||
// console.log(uploadFrom.value.style);
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
|
|
|
|||
Loading…
Reference in New Issue