aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2021-12-07 15:27:05 -0600
committerIván Ávalos <avalos@disroot.org>2021-12-07 15:27:05 -0600
commitbbe3e712ef0c616418057f1b9916984da18e7b38 (patch)
tree439e41d4ab145f7a344190e33928e0e8cbec4a5c /modern/src/map
parent8164e6b30e007a3eeaea25decf98ccb098d9e85f (diff)
downloadetbsa-traccar-web-bbe3e712ef0c616418057f1b9916984da18e7b38.tar.gz
etbsa-traccar-web-bbe3e712ef0c616418057f1b9916984da18e7b38.tar.bz2
etbsa-traccar-web-bbe3e712ef0c616418057f1b9916984da18e7b38.zip
More rebranding para ETBSA!
Diffstat (limited to 'modern/src/map')
-rw-r--r--modern/src/map/Map.js18
-rw-r--r--modern/src/map/PositionsMap.js2
-rw-r--r--modern/src/map/mapUtil.js6
3 files changed, 14 insertions, 12 deletions
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) {*/