Iframe events
Beyond its initial configuration, Map Embedding speaks a small postMessage API. Your page sends commands into the iframe to switch the displayed content, and the embed posts a ready event back to your page once the map settles. Every message is an object with a type field prefixed mountaya:.
Sending commands
To change what the embed shows after it has loaded, post a message to the iframe's contentWindow. One command is available.
mountaya:setItinerarycommand
Switch the map to an itinerary. The message carries itineraryId (a string) plus any of the optional display overrides below.
The command accepts optional display overrides alongside the id. Any field you include is applied; any you omit leaves the embed's current state unchanged. The override fields are camelCase: terrain, withOverlays and withTerrains (arrays of slugs), and the boolean toggles withCollectionItineraries, withCollectionZones, withDownloadControl, withNavigationControl, withOverlaysControl, withPreferencesControl, withProfileAnalysis, withProfileCharacteristics, withProfileElevation, and withStreetviewControl.
A minimal command looks like this:
With overrides, switching content and changing the terrain in one message:
Post the message to the iframe's contentWindow, targeting the embed's origin (https://app.mountaya.com).
Listening for events
Once the map finishes loading, or settles with an error, the embed posts a single mountaya:ready event to the parent window. Listen for it with a message handler and key on the message type.
The ready event always carries these fields:
typestring
Always "mountaya:ready". Key your handler on this so you ignore unrelated messages.
errorstring | null
null on a clean load. Otherwise "timeout" if the map did not finish loading in time, or "not_found" if the requested content could not be resolved. The field is always present, so test error === null for success.
bounds[number, number, number, number] | null
The visible viewport extent as [west, south, east, north] in WGS 84, or null when the load ended in an error.
itineraryIdstring | null
The active itinerary id, or null if none is displayed.
terrainstring
The resolved basemap terrain slug.
A successful ready event looks like this:
The embed posts the ready event with a wildcard target origin, so verify the message came from the Mountaya origin by checking event.origin before trusting it.