diff --git a/packages/primitive-geojson/src/GeoJsonLayer-util.ts b/packages/primitive-geojson/src/GeoJsonLayer-util.ts index e90c033..a3ae0ad 100644 --- a/packages/primitive-geojson/src/GeoJsonLayer-util.ts +++ b/packages/primitive-geojson/src/GeoJsonLayer-util.ts @@ -158,7 +158,7 @@ export function createPoint( }); } else { /** add billboard */ - let canvasOrPromise; + let canvasOrPromise: HTMLCanvasElement | Promise; if (symbol !== '' && defined(symbol)) { // 自定义图片 if (isCustom) { @@ -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; }) @@ -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((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( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 666a1e9..e4fe215 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,37 +109,37 @@ importers: packages/cesium-extends: dependencies: '@cesium-extends/compass': - specifier: 1.2.1 + specifier: 1.2.2 version: link:../compass '@cesium-extends/drawer': - specifier: 1.3.6 + specifier: 1.3.7 version: link:../drawer '@cesium-extends/geojson-render': - specifier: 1.0.7 + specifier: 1.0.8 version: link:../geojson-render '@cesium-extends/heat': - specifier: 1.0.3 + specifier: 1.0.4 version: link:../heat '@cesium-extends/measure': - specifier: 1.1.3 + specifier: 1.1.4 version: link:../measure '@cesium-extends/popup': - specifier: 1.0.1 + specifier: 1.0.2 version: link:../popup '@cesium-extends/primitive-geojson': - specifier: 1.0.9 + specifier: 1.0.10 version: link:../primitive-geojson '@cesium-extends/subscriber': - specifier: 1.1.0 + specifier: 1.1.1 version: link:../subscriber '@cesium-extends/sync-viewer': - specifier: 1.0.0 + specifier: 1.0.1 version: link:../sync-viewer '@cesium-extends/tooltip': - specifier: 1.2.2 + specifier: 1.2.3 version: link:../tooltip '@cesium-extends/zoom-control': - specifier: 1.2.1 + specifier: 1.2.2 version: link:../zoom-controller cesium: specifier: '*' @@ -250,7 +250,7 @@ importers: version: 4.0.2 devDependencies: '@cesium-extends/subscriber': - specifier: 1.1.0 + specifier: 1.1.1 version: link:../subscriber '@types/geojson': specifier: ^7946.0.10