Controlling maps
Last updated
Last updated
The Felt SDK has a number of methods for interacting with maps, depending on how you set up your HTML.
All Felt maps are embedded in iframes, and the SDK can do this for you or can connect to an existing Felt iframe.
Felt map IDs are unique identifiers for Felt maps. They are used to embed maps in iframes, and to connect to existing iframes.
To get the ID of a Felt map, click the Map settings button in the main toolbar, and then you can see the Map ID in the Developers section.
Alternatively, you can look at the URL of the map. For example, the map at https://felt.com/map/Map-title-xPV9BqMuYQxmUraVWy9C89BNA
has the ID xPV9BqMuYQxmUraVWy9C89BNA
.
Throughout the documentation, we'll use the placeholder FELT_MAP_ID
to refer to a Felt map ID.
Felt.embed
to create an iframeCreate an HTML page with a container element:
Embed a Felt map in your container element and use the SDK to control it by calling Felt.embed
, passing the container element as the first argument:
Felt.embed
to mount into an existing iframeIn some cases, you may want to add a "template" iframe to your page. This can be useful if you want to style your iframe in a specific way, or if you already have one map embedded and want to mount and control a different map.
In this case, you can call Felt.embed
with the iframe element as the first argument:
Felt.connect
to connect to an existing embedded Felt mapThere may be cases where you already have a Felt map embedded in an iframe, and you want to control it using the SDK. This can be useful if your HTML is server-rendered with the Felt map already embedded.
In this case, you can call Felt.connect
with the iframe's window as the first argument:
Note that in this case, you don't need to pass the Felt map ID to Felt.connect
, because we are connecting to a map that has already been embedded.