Skip to main content

kaleidr.js — the loader

One script tag installs window.Kaleidr and defines the <kaleidr-map> element:

<script src="https://cdn.kaleidr.com/embed/v1/kaleidr.js"></script>

The façade is a thin loader. It owns only: version, config, script loading, the product registry, key passing, doorway selection, mount lifecycle, error normalization, and the dormancy flag. Each product's real behaviour lives in its own bundle, lazy-loaded by URL on first use.

Kaleidr.mount(target, options) → KaleidrHandle

const handle = Kaleidr.mount('#chat', {
product: 'chat',
publishableKey: 'kld_pk_live_…',
map: myMap,
});

Returns a handle synchronously while the product bundle loads in the background; calls before load are queued and flushed on ready.

Options

OptionTypeNotes
product'chat'|'viewer'|'editor'|'tile'Required. Selects the bundle + default doorway.
publishableKeystringPublishable browser key (kld_pk_live_…). Required for chat/editor/tile; viewer needs none. The SDK exchanges it for a short-lived session at runtime.
apiKeystringDeprecated alias for publishableKey; also accepts a legacy kld_live_… key.
shareId / mapIdstringViewer: the published-map id.
styleIdstringTile/editor: a Kaleidr basemap style id (or full style URL for editor). Omitted, the organization's stored default applies, then kaleidr-morning.
mapmap instanceChat: your live in-page map to attach to.
mapTargetstringChat: CSS selector of a host map element (declarative path).
center zoom pitch bearingInitial camera.
themestring | objectNamed theme or token bag.
doorway'iframe'|'attach'Escape hatch — overrides the product default.
basestringOverride the CDN origin bundles load from (dev / self-host).
viewerBasestringViewer/tile only: the origin the iframe points at. Distinct from base — the iframe never aims at the CDN.
apiBasestringPlatform API origin for the chat product's inference path.
enabledbooleanPer-mount dormancy override.

KaleidrHandle

interface KaleidrHandle {
product: 'chat' | 'viewer' | 'editor' | 'tile';
setCamera?(camera): void; // present where the product supports it
setTheme?(theme): void;
destroy(): void; // always present
}

Kaleidr.init()

Upgrades any <kaleidr-map> already in the DOM. Called automatically on load; call it after injecting elements dynamically.

Kaleidr.enable(on = true)

The SDK is live by default — you don't need to enable anything, and the quickstart works as written.

enable() exists as an off switch: passing false stops mount() from loading any bundle, so you can gate embeds behind a consent banner or kill them on a page without removing the markup. The same switch is available as window.__KALEIDR_EMBED_ENABLED__ = false (before the script runs) or the flag attribute / enabled option per mount.

Kaleidr.version

The loader version string.

CDN base override

For local dev or self-hosting, point the loader at another origin:

<script>window.__KALEIDR_EMBED_BASE__ = 'https://cdn-dev.kaleidr.com';</script>