[fix](trx-frontend): default map sources to hide bookmarks
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -3219,11 +3219,13 @@ let aprsMapBaseLayer = null;
|
|||||||
let aprsMapReceiverMarker = null;
|
let aprsMapReceiverMarker = null;
|
||||||
let aprsRadioPath = null;
|
let aprsRadioPath = null;
|
||||||
let selectedLocatorMarker = null;
|
let selectedLocatorMarker = null;
|
||||||
|
let selectedLocatorPulseRaf = null;
|
||||||
let mapFullscreenListenerBound = false;
|
let mapFullscreenListenerBound = false;
|
||||||
const stationMarkers = new Map();
|
const stationMarkers = new Map();
|
||||||
const locatorMarkers = new Map();
|
const locatorMarkers = new Map();
|
||||||
const mapMarkers = new Set();
|
const mapMarkers = new Set();
|
||||||
const mapFilter = { ais: true, vdes: true, aprs: true, bookmark: true, ft8: true, wspr: true };
|
const DEFAULT_MAP_SOURCE_FILTER = { ais: true, vdes: true, aprs: true, bookmark: false, ft8: true, wspr: true };
|
||||||
|
const mapFilter = { ...DEFAULT_MAP_SOURCE_FILTER };
|
||||||
const mapLocatorFilter = { phase: "type", bands: new Set() };
|
const mapLocatorFilter = { phase: "type", bands: new Set() };
|
||||||
const APRS_TRACK_MAX_POINTS = 64;
|
const APRS_TRACK_MAX_POINTS = 64;
|
||||||
const AIS_TRACK_MAX_POINTS = 64;
|
const AIS_TRACK_MAX_POINTS = 64;
|
||||||
@@ -3489,6 +3491,14 @@ function locatorEntryCount(entry) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function locatorEntryForMarker(marker) {
|
||||||
|
if (!marker) return null;
|
||||||
|
for (const entry of locatorMarkers.values()) {
|
||||||
|
if (entry?.marker === marker) return entry;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function syncLocatorMarkerStyles() {
|
function syncLocatorMarkerStyles() {
|
||||||
for (const entry of locatorMarkers.values()) {
|
for (const entry of locatorMarkers.values()) {
|
||||||
if (!entry?.marker) continue;
|
if (!entry?.marker) continue;
|
||||||
@@ -3496,6 +3506,34 @@ function syncLocatorMarkerStyles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopSelectedLocatorPulse() {
|
||||||
|
if (selectedLocatorPulseRaf != null) {
|
||||||
|
cancelAnimationFrame(selectedLocatorPulseRaf);
|
||||||
|
selectedLocatorPulseRaf = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSelectedLocatorPulse(marker) {
|
||||||
|
stopSelectedLocatorPulse();
|
||||||
|
if (!marker || !aprsMap || !aprsMap.hasLayer(marker)) return;
|
||||||
|
const tick = (ts) => {
|
||||||
|
if (!selectedLocatorMarker || selectedLocatorMarker !== marker || !aprsMap || !aprsMap.hasLayer(marker)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const entry = locatorEntryForMarker(marker);
|
||||||
|
const base = locatorStyleForEntry(entry, locatorEntryCount(entry));
|
||||||
|
const phase = (ts % 1600) / 1600;
|
||||||
|
const wave = (Math.sin(phase * Math.PI * 2 - Math.PI / 2) + 1) / 2;
|
||||||
|
marker.setStyle({
|
||||||
|
...base,
|
||||||
|
opacity: Math.min(1, (base.opacity || 0.8) + 0.12 * wave),
|
||||||
|
weight: (base.weight || 1.8) + 1.8 * wave,
|
||||||
|
});
|
||||||
|
selectedLocatorPulseRaf = requestAnimationFrame(tick);
|
||||||
|
};
|
||||||
|
selectedLocatorPulseRaf = requestAnimationFrame(tick);
|
||||||
|
}
|
||||||
|
|
||||||
function clearMapRadioPath() {
|
function clearMapRadioPath() {
|
||||||
if (aprsRadioPath) {
|
if (aprsRadioPath) {
|
||||||
aprsRadioPath.remove();
|
aprsRadioPath.remove();
|
||||||
@@ -3543,10 +3581,16 @@ function setLocatorMarkerHighlight(marker, enabled) {
|
|||||||
function setSelectedLocatorMarker(marker) {
|
function setSelectedLocatorMarker(marker) {
|
||||||
if (selectedLocatorMarker && selectedLocatorMarker !== marker) {
|
if (selectedLocatorMarker && selectedLocatorMarker !== marker) {
|
||||||
setLocatorMarkerHighlight(selectedLocatorMarker, false);
|
setLocatorMarkerHighlight(selectedLocatorMarker, false);
|
||||||
|
const prevEntry = locatorEntryForMarker(selectedLocatorMarker);
|
||||||
|
if (prevEntry?.marker) {
|
||||||
|
prevEntry.marker.setStyle(locatorStyleForEntry(prevEntry, locatorEntryCount(prevEntry)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
stopSelectedLocatorPulse();
|
||||||
selectedLocatorMarker = marker || null;
|
selectedLocatorMarker = marker || null;
|
||||||
if (selectedLocatorMarker) {
|
if (selectedLocatorMarker) {
|
||||||
setLocatorMarkerHighlight(selectedLocatorMarker, true);
|
setLocatorMarkerHighlight(selectedLocatorMarker, true);
|
||||||
|
startSelectedLocatorPulse(selectedLocatorMarker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3568,10 +3612,16 @@ function renderMapLocatorChipRow(container, items, selectedSet, kind) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let helperText = "";
|
let helperText = "";
|
||||||
const isDefaultSourceState = kind === "source" && items.every((item) => mapFilter[item.key]);
|
const isDefaultSourceState = kind === "source"
|
||||||
|
&& items.every((item) => {
|
||||||
|
const def = Object.prototype.hasOwnProperty.call(DEFAULT_MAP_SOURCE_FILTER, item.key)
|
||||||
|
? !!DEFAULT_MAP_SOURCE_FILTER[item.key]
|
||||||
|
: true;
|
||||||
|
return !!mapFilter[item.key] === def;
|
||||||
|
});
|
||||||
if (kind === "source") {
|
if (kind === "source") {
|
||||||
if (isDefaultSourceState) {
|
if (isDefaultSourceState) {
|
||||||
helperText = "All sources visible by default";
|
helperText = "Default: all non-bookmark sources visible";
|
||||||
}
|
}
|
||||||
} else if (!(selectedSet instanceof Set) || selectedSet.size === 0) {
|
} else if (!(selectedSet instanceof Set) || selectedSet.size === 0) {
|
||||||
helperText = `All ${kind === "band" ? "bands" : "sources"} visible by default`;
|
helperText = `All ${kind === "band" ? "bands" : "sources"} visible by default`;
|
||||||
@@ -3582,7 +3632,14 @@ function renderMapLocatorChipRow(container, items, selectedSet, kind) {
|
|||||||
btn.className = "map-locator-chip";
|
btn.className = "map-locator-chip";
|
||||||
const isActive = kind === "source" ? !!mapFilter[item.key] : selectedSet.has(item.key);
|
const isActive = kind === "source" ? !!mapFilter[item.key] : selectedSet.has(item.key);
|
||||||
if (kind === "source" && isDefaultSourceState) {
|
if (kind === "source" && isDefaultSourceState) {
|
||||||
btn.classList.add("is-default");
|
const def = Object.prototype.hasOwnProperty.call(DEFAULT_MAP_SOURCE_FILTER, item.key)
|
||||||
|
? !!DEFAULT_MAP_SOURCE_FILTER[item.key]
|
||||||
|
: true;
|
||||||
|
if (def) {
|
||||||
|
btn.classList.add("is-default");
|
||||||
|
} else {
|
||||||
|
btn.classList.add("is-inactive");
|
||||||
|
}
|
||||||
} else if (!isActive) {
|
} else if (!isActive) {
|
||||||
btn.classList.add("is-inactive");
|
btn.classList.add("is-inactive");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user