aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/mapManager.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-10-24 15:32:00 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-10-24 15:32:00 -0700
commit4b192b870dfd4fc1eb61b244bbe455a59f7089c3 (patch)
tree4936dcb1a70ba034315ac1bef6e40fbacf005c63 /modern/src/map/mapManager.js
parent50505e02d2464a5f353aa805c9622c6d4f940ebc (diff)
downloadtrackermap-web-4b192b870dfd4fc1eb61b244bbe455a59f7089c3.tar.gz
trackermap-web-4b192b870dfd4fc1eb61b244bbe455a59f7089c3.tar.bz2
trackermap-web-4b192b870dfd4fc1eb61b244bbe455a59f7089c3.zip
Implement category icons
Diffstat (limited to 'modern/src/map/mapManager.js')
-rw-r--r--modern/src/map/mapManager.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/modern/src/map/mapManager.js b/modern/src/map/mapManager.js
index 5c0510c4..e496a6c5 100644
--- a/modern/src/map/mapManager.js
+++ b/modern/src/map/mapManager.js
@@ -1,5 +1,6 @@
import 'mapbox-gl/dist/mapbox-gl.css';
import mapboxgl from 'mapbox-gl';
+import { deviceCategories } from '../common/deviceCategories';
let readyListeners = [];
@@ -32,8 +33,9 @@ const loadIcon = async (key, background, url) => {
const context = canvas.getContext('2d');
context.drawImage(background, 0, 0, canvas.width, canvas.height);
- const imageWidth = image.width * pixelRatio;
- const imageHeight = image.height * pixelRatio;
+ 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);
map.addImage(key, context.getImageData(0, 0, canvas.width, canvas.height), { pixelRatio });
@@ -156,9 +158,7 @@ map.addControl(new mapboxgl.NavigationControl());
map.on('load', async () => {
const background = await loadImage('images/background.svg');
- await Promise.all([
- loadIcon('icon-marker', background, 'images/icon/marker.svg'),
- ]);
+ await Promise.all(deviceCategories.map(async category => loadIcon(category, background, `images/icon/${category}.svg`)));
if (readyListeners) {
readyListeners.forEach(listener => listener());
readyListeners = null;