Fist Push
This commit is contained in:
parent
dd63653413
commit
cab9de1e90
118 changed files with 364726 additions and 0 deletions
45
public old/scripts/fetching.js
Normal file
45
public old/scripts/fetching.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import customIcons from './iconsMap.js';
|
||||
|
||||
const overlayMaps = {};
|
||||
|
||||
async function getOverlayMaps() {
|
||||
await Promise.all(Object.keys(overlayMapsTemplate).map(async (key) => {
|
||||
const url = `/poi/${key.toLowerCase()}/`;
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
let icon = overlayMapsTemplate[key].icon;
|
||||
overlayMaps[key] = L.layerGroup(data.map((item) => L.marker([item.y, item.x], { icon: icon }).bindPopup(item.description)));
|
||||
} catch (error) {
|
||||
console.error(`Error fetching ${key} data:`, error);
|
||||
}
|
||||
}));
|
||||
return overlayMaps;
|
||||
}
|
||||
|
||||
// Fonction pour récupérer les positions des personnages
|
||||
async function getPlayersLocations() {
|
||||
const url = `/characterloc`;
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
let data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching ${key} data:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// overlayMapsTemplate est l'objet avec les clés que vous avez définies
|
||||
const overlayMapsTemplate = {
|
||||
Ringways: { icon: customIcons.blueCircleVoidIcon },
|
||||
Gateways: { icon: customIcons.blueCircleFullIcon },
|
||||
PoI: { icon: customIcons.blueCrossFullIcon },
|
||||
Town: { icon: customIcons.yellowSquareFullIcon },
|
||||
Outpost: { icon: customIcons.yellowSquareVoidIcon },
|
||||
Vault: { icon: customIcons.redCrossFullIcon },
|
||||
Dungeon: { icon: customIcons.redCrossVoidIcon },
|
||||
City: { icon: customIcons.yellowCrownIcon },
|
||||
Faction: { icon: customIcons.greySquareIcon },
|
||||
};
|
||||
|
||||
export { getOverlayMaps, getPlayersLocations };
|
||||
Loading…
Add table
Add a link
Reference in a new issue