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:
+16
-3
@@ -183,6 +183,7 @@ async function login() {
|
||||
if (!keys) await ensureKeys();
|
||||
accessToken = await client.loginWithSignature(keys.publicKey, keys.privateKey);
|
||||
client.setAccessToken(accessToken);
|
||||
await refreshFeatures();
|
||||
}
|
||||
|
||||
async function ensureCollection() {
|
||||
@@ -247,8 +248,20 @@ function renderAssets(features) {
|
||||
}
|
||||
|
||||
async function refreshFeatures() {
|
||||
if (!collectionId) return;
|
||||
const { features } = await client.listFeatures(collectionId);
|
||||
if (!accessToken) return;
|
||||
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();
|
||||
for (const feature of features) {
|
||||
const coords = feature.geometry?.coordinates;
|
||||
@@ -333,7 +346,7 @@ document.getElementById("register").onclick = async () => {
|
||||
document.getElementById("login").onclick = async () => {
|
||||
try {
|
||||
await login();
|
||||
setStatus("Logged in.");
|
||||
setStatus("Logged in. Loaded all collections on map.");
|
||||
} catch (error) {
|
||||
setStatus(error.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user