Terrain Viewer
Features

Cloud Storage

Save a view to your own Dropbox or Google Drive, next to the AT Protocol saved views: list, open, delete, and share a link. Beta, and only where the deployment is registered with the provider.

The Save view fold of the Share dialog has one tab per place a view can be saved to, among those the copy of the app you use is registered with:

TabWhere the view goesWho can read itLink anyone opens
Blueskyone record of your AT Protocol account (Saved Views)anyone with its addressalways, ?view=at/…
Dropboxtwo files in the app's folder of your Dropbox (Apps/<app name>/)you, until you copy a linkafter Copy link, ?view=dropbox/…
Drivetwo files in a Terrain Viewer folder of your Google Driveyou, until you copy a linkafter Copy link, ?view=gdrive/…, if the deployment has a Drive API key

The design follows kepler.gl's "cloud providers" (the demo app saves a map to Dropbox or Google Drive and lists it with a thumbnail). The app still has no server: each tab talks to the provider straight from the browser, with your own sign-in.

Turn it on

The tabs share the saved views' beta flag: Settings → Saved views: AT Protocol, Dropbox, Google Drive → Beta. A link (?view=…) opens for everyone, flag or not.

A provider the copy of the app is not registered with has no tab: the Dropbox tab shows only when the build has VITE_DROPBOX_APP_KEY, the Drive tab only with VITE_GOOGLE_CLIENT_ID. When neither is there, the fold has no tab bar at all, just the Bluesky panel. The public copies are registered only once their owner has done the steps in Register the app.

Save, list, open, share, delete

  1. Pick the tab, then Sign in to Dropbox (the page goes to Dropbox and comes back with the dialog open) or Sign in to Google Drive (a Google window opens; allow popups for the site if the browser blocks it).
  2. Type a title (optional), keep or clear Include a picture of the map, press Save view.
  3. Your saved views lists them, newest first, with their picture, title and date. Each row has:
    • Open: downloads the file and opens the view in this tab.
    • Copy link: the first time, asks Make public?. Saying Share makes that one file readable by anyone who has its link (a Dropbox shared link, a Drive "anyone with the link" permission), then copies https://…/?view=dropbox/… or ?view=gdrive/…. Nothing else of your storage is shared.
    • Delete: asks once, then removes the view and its picture. A shared link then answers "This view no longer exists".
  4. The folder button opens the folder in Dropbox or Drive, where you can rename, move to trash or stop sharing a file yourself.

What is stored

Each view is two files with the same name: <title> <date>.tvview.json and <title> <date>.jpg. The JSON file is the same record as an AT Protocol saved view (see Saved Views, for developers): the view's parameters as the address bar spells them, the title, the date, the mode, the host and build. API keys are never in it, and a key inside a source address becomes a placeholder, as for the AT Protocol: the tab warns when it happens.

Access the app asks for

  • Dropbox: an App folder app. It sees only Apps/<app name>/ in your Dropbox, nothing else.
  • Google Drive: the drive.file scope. The app sees only the files it created (its folder and the views in it), not the rest of your Drive.

Sign-in tokens stay in the browser's storage. A Dropbox sign-in renews itself; a Google one lasts an hour, after which the next action may show Google's window again for a moment. Sign out revokes the token.

  • A link opens for anyone only while the file stays shared. Stop sharing it, or delete it, and the link answers with an error, and the app opens on its default view.
  • A Drive link needs a Google API key in the deployment: VITE_GOOGLE_DRIVE_API_KEY, or, when that one is absent, the app's general VITE_GOOGLE_API_KEY. Google serves a public file to a web page only through its API, with a key. Without either, Drive views stay private and the Drive tab has no Copy link; open them from the list. When Google answers 403 to a link, the key does not allow the Google Drive API or the site's address: the message says so.
  • As for AT Protocol short links, a chat or social network that unfurls a ?view= link shows the site's generic preview, not the view's picture.

Register the app

Only whoever deploys a copy of the app can do this, once per provider. Both ids are public by design (they end up in the page), they are not secrets; still, they go in the build's .env, never in the repository. The deploy workflow writes .env from the ENV_FILE_CONTENT secret: add the lines there.

The app finishes a sign-in on the site's root page. The redirect addresses (Dropbox) and JavaScript origins (Google) to register are:

https://terrain-viewer.iconem.com/
https://historical-satellite.iconem.com/
http://localhost:5173/
http://localhost:5174/

(Google asks for origins without the trailing slash: https://terrain-viewer.iconem.com, …)

Dropbox

  1. Dropbox App Console → Create app → Scoped access → App folder → a name (it becomes the folder name, Apps/<name>/).
  2. Permissions tab: tick account_info.read, files.metadata.read, files.content.read, files.content.write, sharing.read, sharing.write, then Submit.
  3. Settings tab: add each address above to Redirect URIs. Leave Allow public clients (Implicit Grant & PKCE) on.
  4. Copy the App key (not the secret, which the app never uses) to .env: VITE_DROPBOX_APP_KEY=….
  5. A new app is in development status, open to its owner and up to 500 users; Apply for production in the console when more people use it.

Google Drive

  1. Google Cloud console → a project → APIs & Services → Library → enable Google Drive API.
  2. OAuth consent screen (Google Auth Platform): user type External, the app name, a support address, and the scope .../auth/drive.file. Until the app is published, add the people who test it as test users. drive.file is a non-sensitive scope: publishing needs no security review.
  3. Credentials → Create credentials → OAuth client ID → Web application: add the origins above to Authorized JavaScript origins (no redirect URI is needed: the sign-in is a popup). Copy the client id to .env: VITE_GOOGLE_CLIENT_ID=….apps.googleusercontent.com.
  4. Optional, for public links: an API key. It is made in APIs & Services → Credentials → + Create credentials → API key, not on the Google Auth Platform's Clients page, which only makes OAuth clients. Restrict it to the Google Drive API and, under Website restrictions, to the site's addresses (https://terrain-viewer.iconem.com/*, …). Copy it to .env: VITE_GOOGLE_DRIVE_API_KEY=…. Without it the app reads public Drive links with VITE_GOOGLE_API_KEY, the key it already uses for Google's map tiles; that key must then allow the Google Drive API and the site's addresses too.

Rebuild (or restart pnpm app): the Dropbox or Drive tab appears.

For developers

Files. lib/cloud-storage/provider.ts is the shape every provider has: login, getUser, logout, uploadView, listViews, getThumbnail, downloadView, deleteView, getShareUrl, getManagementUrl, hasSharingUrl. It is kepler.gl's Provider class (@kepler.gl/cloud-providers, MIT), ported rather than imported: the package depends on React and @kepler.gl/types, and its map type is kepler's own. lib/cloud-storage/dropbox.ts and google-drive.ts adapt the kepler.gl demo app's providers (Dropbox with PKCE and plain fetch instead of the SDK and the implicit grant). lib/cloud-storage/atproto.ts wraps lib/view-sharing.ts in the same shape. lib/cloud-storage/view-file.ts has no dependency: the file, its names, the dropbox/… and gdrive/… references and their public read, and the PKCE pair. The UI is components/TerrainControlPanel/CloudViewsPanel.tsx; its Bluesky tab is the existing SavedViewPanel.tsx.

Arrival. src/main.tsx settles, before React starts, the way back from a Dropbox sign-in (?code=…&state=dbx.…, the code traded for a token, the address put back) and a ?view=dropbox/… or ?view=gdrive/… link (one public download: Dropbox's dl.dropboxusercontent.com answers any origin, Drive's API answers with the key; then the address becomes the full link, as for ?view=at/…).

References. dropbox/<id>/<rlkey>/<file name> for a shared link https://www.dropbox.com/scl/fi/<id>/<file name>?rlkey=<rlkey>, dropbox/s/<id>/<file name> for the older form, gdrive/<file id>.

Tests. node scripts/test-lib.mjs lib/cloud-storage/view-file.test.ts (offline).

On this page