aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/mapUtil.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-06-26 18:25:45 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-06-26 18:25:45 -0700
commitde199fa668b61ca1def0b8d18de8d666d8148361 (patch)
tree7eaace63676732087f2348c1201d580ba120b207 /modern/src/map/mapUtil.js
parent698e27607bddd10a2f5b10a5ff07692a3d1f4ae0 (diff)
downloadetbsa-traccar-web-de199fa668b61ca1def0b8d18de8d666d8148361.tar.gz
etbsa-traccar-web-de199fa668b61ca1def0b8d18de8d666d8148361.tar.bz2
etbsa-traccar-web-de199fa668b61ca1def0b8d18de8d666d8148361.zip
Implement map clustering
Diffstat (limited to 'modern/src/map/mapUtil.js')
-rw-r--r--modern/src/map/mapUtil.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/modern/src/map/mapUtil.js b/modern/src/map/mapUtil.js
index e7dc032..4780940 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);
};