diff --git a/src/meshcore_hub/web/templates/map.html b/src/meshcore_hub/web/templates/map.html
index 127a97a..445a5f7 100644
--- a/src/meshcore_hub/web/templates/map.html
+++ b/src/meshcore_hub/web/templates/map.html
@@ -16,22 +16,6 @@
.leaflet-popup-tip {
background: oklch(var(--b1));
}
- .marker-chat {
- background-color: oklch(var(--p));
- }
- .marker-repeater {
- background-color: oklch(var(--s));
- }
- .marker-room {
- background-color: oklch(var(--a));
- }
- .marker-default {
- background-color: oklch(var(--n));
- }
- .marker-infra {
- border: 3px solid gold !important;
- box-shadow: 0 0 8px gold, 0 2px 4px rgba(0,0,0,0.3) !important;
- }
{% endblock %}
@@ -89,23 +73,23 @@
@@ -131,23 +115,23 @@
let markers = [];
let mapCenter = { lat: {{ network_location[0] }}, lon: {{ network_location[1] }} };
- // Get marker color class based on node type
- function getMarkerClass(node) {
- let baseClass = 'marker-default';
- if (node.adv_type === 'chat') baseClass = 'marker-chat';
- else if (node.adv_type === 'repeater') baseClass = 'marker-repeater';
- else if (node.adv_type === 'room') baseClass = 'marker-room';
-
- if (node.is_infra) baseClass += ' marker-infra';
- return baseClass;
+ // Get marker color based on node type
+ function getMarkerColor(node) {
+ if (node.adv_type === 'chat') return 'oklch(var(--p))';
+ if (node.adv_type === 'repeater') return 'oklch(var(--s))';
+ if (node.adv_type === 'room') return 'oklch(var(--a))';
+ return 'oklch(var(--n))';
}
// Create marker icon for a node
function createNodeIcon(node) {
- const markerClass = getMarkerClass(node);
+ const color = getMarkerColor(node);
+ const infraStyle = node.is_infra
+ ? 'border: 3px solid gold; box-shadow: 0 0 8px gold, 0 2px 4px rgba(0,0,0,0.3);'
+ : 'border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.3);';
return L.divIcon({
className: 'custom-div-icon',
- html: ``,
+ html: ``,
iconSize: [12, 12],
iconAnchor: [6, 6]
});
@@ -191,8 +175,8 @@
markers = [];
}
- // Apply filters and update map
- function applyFilters() {
+ // Core filter logic - returns filtered nodes and updates markers
+ function applyFiltersCore() {
const typeFilter = document.getElementById('filter-type').value;
const ownerFilter = document.getElementById('filter-owner').value;
const infraOnly = document.getElementById('filter-infra').checked;
@@ -236,6 +220,13 @@
filteredEl.classList.remove('hidden');
}
+ return filteredNodes;
+ }
+
+ // Apply filters and recenter map on filtered nodes
+ function applyFilters() {
+ const filteredNodes = applyFiltersCore();
+
// Fit bounds if we have filtered nodes
if (filteredNodes.length > 0) {
const bounds = L.latLngBounds(filteredNodes.map(n => [n.lat, n.lon]));
@@ -245,6 +236,11 @@
}
}
+ // Apply filters without recentering (for initial load after manual center)
+ function applyFiltersNoRecenter() {
+ applyFiltersCore();
+ }
+
// Populate owner filter dropdown
function populateOwnerFilter() {
const select = document.getElementById('filter-owner');
@@ -299,8 +295,14 @@
// Populate owner filter
populateOwnerFilter();
- // Initial display
- applyFilters();
+ // Initial display - center map on nodes if available
+ if (allNodes.length > 0) {
+ const bounds = L.latLngBounds(allNodes.map(n => [n.lat, n.lon]));
+ map.fitBounds(bounds, { padding: [50, 50] });
+ }
+
+ // Apply filters (won't re-center since we just did above)
+ applyFiltersNoRecenter();
})
.catch(error => {
console.error('Error loading map data:', error);