Skip to content

Commit

Permalink
fix: ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfaqiu committed Dec 2, 2024
1 parent 4e908ee commit c4a3a35
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
29 changes: 17 additions & 12 deletions packages/primitive-geojson/src/GeoJsonLayer-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function createPoint(
});
} else {
/** add billboard */
let canvasOrPromise;
let canvasOrPromise: HTMLCanvasElement | Promise<HTMLCanvasElement>;
if (symbol !== '' && defined(symbol)) {
// 自定义图片
if (isCustom) {
Expand Down Expand Up @@ -197,9 +197,11 @@ export function createPoint(

const promise = Promise.resolve(canvasOrPromise)
.then(function (image) {
image instanceof Promise ? image.then(i => {
billboard.image = i;
}) : (billboard.image = image)
image instanceof Promise
? image.then((i) => {
billboard.image = i;
})
: (billboard.image = image as unknown as string);
// @ts-ignore
billboard.image = image;
})
Expand All @@ -212,29 +214,32 @@ export function createPoint(
}
}

function processImage(url: string | ((arg0: any) => string), size: number | number[], properties: any) {
function processImage(
url: string | ((arg0: any) => string),
size: number | number[],
properties: any,
) {
let height = 24;
let width = 24;
if (Array.isArray(size)) {
height = size[0];
width = size[1];
}else{
} else {
height = size;
width = size;
}
return new Promise((resolve) => {
let canvas = document.createElement('canvas');
return new Promise<HTMLCanvasElement>((resolve) => {
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
let img = new Image();
const img = new Image();
img.onload = () => {
ctx?.drawImage(img, 0, 0, width, height);
resolve(canvas);
}
};
img.src = url instanceof Function ? url(properties) : url;
})

});
}

export function processPoint(
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4a3a35

Please sign in to comment.