The Audiom Embed Endpoint allows you to integrate the Audiom inclusive mapping solution into your platform using an iFrame. The service dynamically generates an interactive map based on the URL query parameters provided.
The base URL for the embed endpoint typically follows this pattern:
https://[your-audiom-instance-url]/embed/[embedId]
Query parameters are appended to this URL to configure the map.
embedId (Required in URL Path)"dynamic" to load a map dynamically based on query parameters./embed/12345 (loads pre-configured map with ID 12345)/embed/dynamic?source=osm&latitude=47.6495&longitude=-122.1431The following parameters can be passed via the URL query string:
apiKey (Required)apiKey=abcxyz123456sources (Optional)["osm"].sources=osmsources=TDEI,https://example.com/data.geojsonsources=https://example.com/mycustommap.geojsoncenter (Optional)latitude and longitude parameters.center="-122.1431,47.6495"latitude (Optional)center parameter is provided, it takes precedence over latitude and longitude.latitude=47.6495122longitude (Optional)center parameter is provided, it takes precedence over latitude and longitude.longitude=-122.1430782zoom (Optional)0zoom=15soundpack (Optional)embedId or to a system-wide default (e.g., /audio).soundpack=/audio/custompacknamedemo (Optional)"true" or "false")demo=truetitle (Optional)title=My%20Custom%20Interactive%20MapshowVisualMap (Optional)"true" or "false")trueshowVisualMap=false (Hides the visual map, showing only the audio interface)heading (Optional)h1, h2) for the map title when showHeading is true.2 (renders as <h2>)heading=1 (Renders the title as <h1>)showHeading (Optional)"true" or "false")showHeading=truestepsize (Optional)km (kilometers), m (meters, default if no unit), mi (miles), ft (feet)stepsize=10m (10 meters)stepsize=5km (5 kilometers)stepsize=100 (100 meters, assumes meters without unit)For advanced configurations with multiple data sources, you can use namespaced parameters to pass source-specific settings. This works identically to the /map endpoint.
Format: {sourceName}.{parameter}={value}
{source}.type - Override the source loader type
routes.type=esri (forces ESRI loader for “routes” source){source}.mapType - Override the map rendering type for this source
travel, heatmap, indoorelevation.mapType=heatmap{source}.name - Custom display name for the source
osm.name=Street%20Network{source}.url - URL for dynamic sources (required for ESRI type)
weather.url=https://services.arcgis.com/...Complete Example:
/embed/dynamic?source=routes,elevation&routes.type=esri&routes.url=https://example.com/service&elevation.mapType=heatmap&apiKey=xyz123
organizationId, custom parameters for specific data loaders) will be collected and passed as additionalParams to the map data loader. This allows for extending functionality for custom data sources.myCustomParam=customValue (This would be passed to the loader if myCustomParam is not a recognized top-level parameter).The following parameters are available in the /map endpoint but NOT supported in the /embed endpoint:
projection - Coordinate system projection (ENU, UTM, WebMercator)zone - UTM zone numberIf these parameters are passed to the embed endpoint, they will be ignored.
422 Unprocessable EntityapiKey parameter is missing.429 Too Many Requestssource(s) are invalid, data cannot be fetched, or the data is malformed.400 Bad Request, 404 Not Found, 500 Internal Server Error). The specific message will depend on the nature of the error.The Audiom Embed API provides bidirectional communication between embedded maps and parent windows using the postMessage API. This allows external applications to control the embedded map and receive real-time updates about user interactions.
The PostMessage API is disabled by default for security. To enable it, you must specify which origins are allowed to communicate with the embedded map using the allowedOrigins URL parameter.
allowedOrigins (Required to enable API)* to allow any origin.INVALID_ORIGIN error.allowedOrigins=https://myapp.com (single origin)allowedOrigins=https://myapp.com,https://staging.myapp.com (multiple origins)allowedOrigins=* (any origin - use only for development/testing)Complete embed URL example:
/embed/dynamic?source=osm&latitude=47.6495&longitude=-122.1431&apiKey=xyz123&allowedOrigins=https://myapp.com
All messages follow a consistent structure with type and payload properties:
interface Message {
type: string;
payload: object;
}
These events are sent from the embedded Audiom map to your parent window.
readySent when the embed is fully initialized and ready to receive commands.
// Payload
{
apiVersion: "1.0.0" // Semantic version of the API
}
positionChangedSent whenever the avatar’s position changes.
// Payload
{
position: [longitude, latitude] // GeoJSON coordinate order
}
featureEnteredSent when the avatar enters one or more map features (e.g., buildings, parks).
// Payload
{
features: [
{
id: "feature-123",
name: "Central Park",
type: "park",
position: [longitude, latitude],
properties: { /* original feature properties */ }
}
]
}
featureExitedSent when the avatar exits one or more map features.
// Payload
{
features: [
{
id: "feature-123",
name: "", // May be empty for exited features
type: "unknown",
position: [0, 0],
properties: {}
}
]
}
featureSelectedSent when the avatar crosses a feature boundary. Contains all features currently enclosing the avatar.
// Payload
{
features: [/* array of FeaturePayload objects */]
}
stateChangedResponse to a getState query. Contains the current avatar position.
// Payload
{
position: [longitude, latitude]
}
errorSent when an error occurs processing an inbound command.
// Payload
{
code: "INVALID_ORIGIN", // Error code
message: "Origin https://evil.com not allowed" // Human-readable message
}
// Error codes:
// - INVALID_ORIGIN: Message from disallowed origin
// - INVALID_MESSAGE: Message format is invalid
// - UNKNOWN_COMMAND: Unknown command type
// - COMMAND_FAILED: Command execution failed
// - NOT_READY: API not initialized
Send these commands from your parent window to control the embedded map.
moveAvatarMove the avatar to a specific geographic position.
iframe.contentWindow.postMessage({
type: 'moveAvatar',
payload: {
position: [-122.4194, 37.7749] // [longitude, latitude]
}
}, 'https://[your-audiom-instance-url]');
getStateQuery the current avatar position. The embed responds with a stateChanged event.
iframe.contentWindow.postMessage({
type: 'getState'
}, 'https://[your-audiom-instance-url]');
getEnclosingFeaturesQuery the features currently enclosing the avatar. The embed responds with a featureSelected event.
iframe.contentWindow.postMessage({
type: 'getEnclosingFeatures'
}, 'https://[your-audiom-instance-url]');
setFiltersSet feature type filters for global display and/or sonar scanning.
iframe.contentWindow.postMessage({
type: 'setFilters',
payload: {
global: ['building', 'park'], // Types to show globally
scan: ['poi', 'transit'] // Types to include in sonar scan
}
}, 'https://[your-audiom-instance-url]');
executeCommandExecute an Audiom keyboard command programmatically.
iframe.contentWindow.postMessage({
type: 'executeCommand',
payload: {
command: 'announcePosition' // Command name
}
}, 'https://[your-audiom-instance-url]');
// Common commands: 'up', 'down', 'left', 'right', 'toggleSonar', 'announcePosition'
// Get reference to the iframe
const iframe = document.getElementById('audiom-embed');
const audiomOrigin = 'https://your-audiom-instance.com';
// Listen for messages from the embed
window.addEventListener('message', (event) => {
// Security: verify the message origin
if (event.origin !== audiomOrigin) return;
const { type, payload } = event.data;
switch (type) {
case 'ready':
console.log('Audiom ready, API version:', payload.apiVersion);
break;
case 'positionChanged':
console.log('User moved to:', payload.position);
// Update your UI with the new position
updateMapMarker(payload.position);
break;
case 'featureEntered':
console.log('User entered features:', payload.features);
// Show feature info in your sidebar
showFeatureDetails(payload.features);
break;
case 'featureExited':
console.log('User exited features:', payload.features.map(f => f.id));
break;
case 'error':
console.error('Audiom error:', payload.code, payload.message);
break;
}
});
// Send a command to move the avatar
function moveToLocation(lng, lat) {
iframe.contentWindow.postMessage({
type: 'moveAvatar',
payload: { position: [lng, lat] }
}, audiomOrigin);
}
// Query current state
function getCurrentPosition() {
iframe.contentWindow.postMessage({
type: 'getState'
}, audiomOrigin);
}
Always specify explicit origins: Avoid using allowedOrigins=* in production. List only the domains that need to communicate with the embed.
Validate message origins: Always check event.origin in your message handler to ensure messages are from your Audiom instance.
Use HTTPS: Both your application and the Audiom embed should use HTTPS to prevent message interception.
Audiom supports fullscreen mode, which is especially useful during demos and presentations. Users can toggle fullscreen by:
z keyEnter to open)Important: For fullscreen to work within an embedded iframe, you must include the allowfullscreen attribute on your iframe element:
<iframe
src="https://[your-audiom-instance-url]/embed/12345?apiKey=xyz123"
allowfullscreen
></iframe>
Or using the modern Permissions Policy syntax:
<iframe
src="https://[your-audiom-instance-url]/embed/12345?apiKey=xyz123"
allow="fullscreen"
></iframe>
If the allowfullscreen attribute is not present, users will receive an audio message saying “Fullscreen is not available” when attempting to enter fullscreen mode.
For the best user experience, we recommend the following iframe configuration:
<iframe
src="https://[your-audiom-instance-url]/embed/12345?apiKey=xyz123"
title="Audiom Interactive Map"
allowfullscreen
style="width: 100%; height: 600px; border: none;"
></iframe>