diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-26 18:25:45 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-26 18:25:45 -0700 |
commit | de199fa668b61ca1def0b8d18de8d666d8148361 (patch) | |
tree | 7eaace63676732087f2348c1201d580ba120b207 /modern/src/map/mapUtil.js | |
parent | 698e27607bddd10a2f5b10a5ff07692a3d1f4ae0 (diff) | |
download | trackermap-web-de199fa668b61ca1def0b8d18de8d666d8148361.tar.gz trackermap-web-de199fa668b61ca1def0b8d18de8d666d8148361.tar.bz2 trackermap-web-de199fa668b61ca1def0b8d18de8d666d8148361.zip |
Implement map clustering
Diffstat (limited to 'modern/src/map/mapUtil.js')
-rw-r--r-- | modern/src/map/mapUtil.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modern/src/map/mapUtil.js b/modern/src/map/mapUtil.js index e7dc0327..4780940d 100644 --- a/modern/src/map/mapUtil.js +++ b/modern/src/map/mapUtil.js @@ -9,8 +9,7 @@ export const loadImage = (url) => { }); }; -export const loadIcon = async (key, background, url) => { - const image = await loadImage(url); +export const loadIcon = async (background, url) => { const pixelRatio = window.devicePixelRatio; const canvas = document.createElement('canvas'); @@ -22,10 +21,13 @@ export const loadIcon = async (key, background, url) => { const context = canvas.getContext('2d'); context.drawImage(background, 0, 0, canvas.width, canvas.height); - const iconRatio = 0.5; - const imageWidth = canvas.width * iconRatio; - const imageHeight = canvas.height * iconRatio; - context.drawImage(image, (canvas.width - imageWidth) / 2, (canvas.height - imageHeight) / 2, imageWidth, imageHeight); + if (url) { + const image = await loadImage(url); + const iconRatio = 0.5; + const imageWidth = canvas.width * iconRatio; + const imageHeight = canvas.height * iconRatio; + context.drawImage(image, (canvas.width - imageWidth) / 2, (canvas.height - imageHeight) / 2, imageWidth, imageHeight); + } return context.getImageData(0, 0, canvas.width, canvas.height); }; |