From bbe3e712ef0c616418057f1b9916984da18e7b38 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 7 Dec 2021 15:27:05 -0600 Subject: More rebranding para ETBSA! --- modern/src/map/Map.js | 18 +++++++++--------- modern/src/map/PositionsMap.js | 2 +- modern/src/map/mapUtil.js | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'modern/src/map') diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index a5f69e0..10630d8 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -20,6 +20,8 @@ element.style.height = '100%'; export const map = new maplibregl.Map({ container: element, + center: [-100.360, 23.191], + zoom: 5 }); let ready = false; @@ -48,13 +50,11 @@ const initMap = async () => { }); await Promise.all(deviceCategories.map(async (category) => { const results = []; - ['green', 'red', 'gray'].forEach((color) => { - results.push(loadImage(`images/icon/${category}.png`).then((icon) => { - map.addImage(`${category}-${color}`, prepareIcon(background, icon, palette.common[color]), { - pixelRatio: window.devicePixelRatio, - }); - })); - }); + results.push(loadImage(`images/icon/${category.toLowerCase()}.png`).then((icon) => { + map.addImage(`${category.toLowerCase()}-map`, prepareIcon(background, icon, null), { + pixelRatio: window.devicePixelRatio, + }); + })); await Promise.all(results); })); } @@ -62,7 +62,7 @@ const initMap = async () => { }; map.addControl(new maplibregl.NavigationControl({ - showCompass: false, + showCompass: false })); const switcher = new SwitcherControl( @@ -70,7 +70,7 @@ const switcher = new SwitcherControl( () => { const waiting = () => { if (!map.loaded()) { - setTimeout(waiting, 100); + setTimeout(waiting, 2000); } else { initMap(); } diff --git a/modern/src/map/PositionsMap.js b/modern/src/map/PositionsMap.js index 8d10053..f1ac3b7 100644 --- a/modern/src/map/PositionsMap.js +++ b/modern/src/map/PositionsMap.js @@ -104,7 +104,7 @@ const PositionsMap = ({ positions }) => { source: id, filter: ['!', ['has', 'point_count']], layout: { - 'icon-image': '{category}-{color}', + 'icon-image': '{category}-map', 'icon-allow-overlap': true, 'text-field': '{name}', 'text-allow-overlap': true, diff --git a/modern/src/map/mapUtil.js b/modern/src/map/mapUtil.js index ca7b3af..43038ef 100644 --- a/modern/src/map/mapUtil.js +++ b/modern/src/map/mapUtil.js @@ -36,10 +36,12 @@ export const prepareIcon = (background, icon, color) => { canvas.style.height = `${background.height}px`; const context = canvas.getContext('2d'); - context.drawImage(background, 0, 0, canvas.width, canvas.height); + if (!icon) { + context.drawImage(background, 0, 0, canvas.width, canvas.height); + } if (icon) { - const iconRatio = 0.8; + const iconRatio = 1; const imageWidth = canvas.width * iconRatio; const imageHeight = canvas.height * iconRatio; /*if (navigator.userAgent.indexOf('Firefox') > 0) {*/ -- cgit v1.2.3