diff --git a/src/cavnas.js b/src/cavnas.js index ccc4c2b..761cb3c 100644 --- a/src/cavnas.js +++ b/src/cavnas.js @@ -1,13 +1,13 @@ -let globaCanvas; +let globalCanvas; export function getCanvas(tileSize = 256) { - if (!globaCanvas && OffscreenCanvas) { - globaCanvas = new OffscreenCanvas(1, 1); + if (!globalCanvas && OffscreenCanvas) { + globalCanvas = new OffscreenCanvas(1, 1); } - if (globaCanvas) { - globaCanvas.width = globaCanvas.height = tileSize; + if (globalCanvas) { + globalCanvas.width = globalCanvas.height = tileSize; } - return globaCanvas; + return globalCanvas; } function clearCanvas(ctx) { diff --git a/src/tileclip.js b/src/tileclip.js index 08629b5..14abe3d 100644 --- a/src/tileclip.js +++ b/src/tileclip.js @@ -14,7 +14,7 @@ export function isPolygon(feature) { return type === 'Polygon' || type === 'MultiPolygon'; } -export function is3857(projection) { +export function isEPSG3857(projection) { return projection === 'EPSG:3857'; } @@ -48,7 +48,7 @@ function lnglat2Mercator(coordinates) { } function transformCoordinates(projection, coordinates) { - if (!is3857(projection)) { + if (!isEPSG3857(projection)) { return coordinates; } else { const transformRing = (coord) => { @@ -91,7 +91,7 @@ function transformPixels(projection, tileBBOX, tileSize, coordinates) { } return result; }; - if (is3857(projection)) { + if (isEPSG3857(projection)) { const [mminx, mminy] = lnglat2Mercator([minx, miny]); const [mmaxx, mmaxy] = lnglat2Mercator([maxx, maxy]); const mTileBBOX = [mminx, mminy, mmaxx, mmaxy]; diff --git a/src/worker.js b/src/worker.js index 25e6c6d..d2f048d 100644 --- a/src/worker.js +++ b/src/worker.js @@ -23,6 +23,7 @@ export const onmessage = function (message, postResponse) { return; } postResponse(null, image, [image]); + return; } if (type === 'injectMask') { const geojson = injectMask(data.maskId, data.geojsonFeature); @@ -31,9 +32,12 @@ export const onmessage = function (message, postResponse) { return; } postResponse(); + return; } if (type === 'removeMask') { removeMask(data.maskId); postResponse(); + return; } + console.error('not support message type:', type); };