LuminaWebsite/assets/map/js/models/MapData.js
Maaxxs c5213b5736 Karte: replace the tactical map with the interactive map viewer
The Karte page now embeds a standalone viewer (assets/map/) covering all ten
regions - Verteron, Altgard, Elthen, Morheim, Poeta, Ishalgen and the
Reshanta maps - with markers and category filters from interactivemap.app.
map.php loads it in an iframe because its stylesheet restyles body, button
and * globally and would otherwise break the site layout.

The tile, marker and icon data (~230 MB, ~39,000 files) is kept out of Git
and uploaded by FTP; the README explains where it comes from.

Removed with it: own markers and categories, tactic layers, the in-browser
map builder, the tile/stitch/viewer tools, the bundled Leaflet, the four map
tables in schema.sql and the map.manage / map.tactics permissions. Existing
databases keep their old map tables untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 06:54:17 +02:00

131 lines
No EOL
3.8 KiB
JavaScript

/**
* MapData - Model for map information and markers
*/
class MapData {
constructor() {
this.maps = []; // List of available maps
this.currentMap = null; // Currently selected map info
this.markers = []; // Markers for current map
this.categories = {}; // Category metadata (group/name -> info)
this.visibleCategories = new Set();
}
/**
* Add a map to the available maps list
*/
addMap(mapInfo) {
this.maps.push({
id: mapInfo.id,
slug: mapInfo.slug,
name: mapInfo.name,
zone: mapInfo.zone || 'Unknown'
});
}
/**
* Set the current map and clear markers
*/
setCurrentMap(slug) {
const map = this.maps.find(m => m.slug === slug);
if (map) {
this.currentMap = map;
this.markers = [];
this.categories = {};
this.visibleCategories.clear();
}
return map;
}
/**
* Load markers for the current map from JSON data
*/
loadMarkers(jsonData) {
if (!this.currentMap) return;
// Parse and normalize marker data
const rawMarkers = jsonData.markers || [];
this.markers = rawMarkers.map(m => ({
id: m.id,
name: m.name,
description: m.description,
group_name: m.group_name,
category_name: m.category_name,
worldX: m.coordinates ? m.coordinates[1] : 0,
worldY: m.coordinates ? m.coordinates[0] : 0,
color: m.properties?.primary_color || '#FFFFFF',
iconText: m.properties?.icon_text || '',
nt: m.properties?.nt || '',
iconName: m.properties?.icon_name || '',
iconImage: m.properties?.icon_image ? m.properties.icon_image.split('?')[0] : ''
}));
// Build category metadata
this.markers.forEach(m => {
const key = `${m.group_name}/${m.category_name}`;
if (!this.categories[key]) {
this.categories[key] = {
group: m.group_name,
name: m.category_name,
count: 0,
color: CONFIG.CATEGORY_COLORS[m.group_name] || '#FFFFFF',
iconImage: m.iconImage || ''
};
}
this.categories[key].count++;
});
// Show all categories by default
Object.keys(this.categories).forEach(key => {
this.visibleCategories.add(key);
});
}
/**
* Toggle visibility of a category
*/
toggleCategory(key, visible) {
if (visible) {
this.visibleCategories.add(key);
} else {
this.visibleCategories.delete(key);
}
}
/**
* Toggle all categories in a group
*/
toggleGroup(groupName, visible) {
Object.entries(this.categories).forEach(([key, cat]) => {
if (cat.group === groupName) {
this.toggleCategory(key, visible);
}
});
}
/**
* Check if all categories in a group are visible
*/
isGroupFullyVisible(groupName) {
return Object.entries(this.categories)
.filter(([key, cat]) => cat.group === groupName)
.every(([key]) => this.visibleCategories.has(key));
}
/**
* Check if any category in a group is visible
*/
isGroupPartiallyVisible(groupName) {
return Object.entries(this.categories)
.filter(([key, cat]) => cat.group === groupName)
.some(([key]) => this.visibleCategories.has(key));
}
/**
* Get marker count for a category
*/
getCategoryCount(key) {
return this.categories[key]?.count || 0;
}
}