Load all collections on map after login.
CI / test (push) Successful in 3s

Both map demos now fetch all user collections and render their features/assets immediately on login, including 3D objects, instead of only showing a single selected collection.

Made-with: Cursor
This commit is contained in:
2026-03-02 22:17:04 +00:00
parent 50fa9a5a22
commit b833c2ac6e
2 changed files with 39 additions and 6 deletions
+23 -3
View File
@@ -118,6 +118,7 @@ async function login() {
if (!keys) await ensureKeys(); if (!keys) await ensureKeys();
accessToken = await client.loginWithSignature(keys.publicKey, keys.privateKey); accessToken = await client.loginWithSignature(keys.publicKey, keys.privateKey);
client.setAccessToken(accessToken); client.setAccessToken(accessToken);
await refreshFeatures();
} }
async function ensureCollection() { async function ensureCollection() {
@@ -181,9 +182,28 @@ function renderAssets(features) {
} }
} }
function clearMarkers() {
for (const marker of markers.values()) {
map.removeLayer(marker);
}
markers.clear();
}
async function refreshFeatures() { async function refreshFeatures() {
if (!collectionId) return; if (!accessToken) return;
const { features } = await client.listFeatures(collectionId); const { collections } = await client.listCollections();
if (!collectionId && collections.length > 0) {
collectionId = collections[0].id;
collectionInfoEl.textContent = `${collections[0].name} (${collections[0].id})`;
}
const featureSets = await Promise.all(
collections.map(async (collection) => {
const { features } = await client.listFeatures(collection.id);
return features;
})
);
const features = featureSets.flat();
clearMarkers();
for (const feature of features) { for (const feature of features) {
const coords = feature.geometry?.coordinates; const coords = feature.geometry?.coordinates;
if (!coords || coords.length < 2) continue; if (!coords || coords.length < 2) continue;
@@ -271,7 +291,7 @@ document.getElementById("register").onclick = async () => {
document.getElementById("login").onclick = async () => { document.getElementById("login").onclick = async () => {
try { try {
await login(); await login();
setStatus("Logged in."); setStatus("Logged in. Loaded all collections on map.");
} catch (error) { } catch (error) {
setStatus(error.message); setStatus(error.message);
} }
+16 -3
View File
@@ -183,6 +183,7 @@ async function login() {
if (!keys) await ensureKeys(); if (!keys) await ensureKeys();
accessToken = await client.loginWithSignature(keys.publicKey, keys.privateKey); accessToken = await client.loginWithSignature(keys.publicKey, keys.privateKey);
client.setAccessToken(accessToken); client.setAccessToken(accessToken);
await refreshFeatures();
} }
async function ensureCollection() { async function ensureCollection() {
@@ -247,8 +248,20 @@ function renderAssets(features) {
} }
async function refreshFeatures() { async function refreshFeatures() {
if (!collectionId) return; if (!accessToken) return;
const { features } = await client.listFeatures(collectionId); const { collections } = await client.listCollections();
if (!collectionId && collections.length > 0) {
collectionId = collections[0].id;
collectionInfoEl.textContent = `${collections[0].name} (${collections[0].id})`;
}
const featureSets = await Promise.all(
collections.map(async (collection) => {
const { features } = await client.listFeatures(collection.id);
return features;
})
);
const features = featureSets.flat();
clearFeatureMeshes(); clearFeatureMeshes();
for (const feature of features) { for (const feature of features) {
const coords = feature.geometry?.coordinates; const coords = feature.geometry?.coordinates;
@@ -333,7 +346,7 @@ document.getElementById("register").onclick = async () => {
document.getElementById("login").onclick = async () => { document.getElementById("login").onclick = async () => {
try { try {
await login(); await login();
setStatus("Logged in."); setStatus("Logged in. Loaded all collections on map.");
} catch (error) { } catch (error) {
setStatus(error.message); setStatus(error.message);
} }