Map-Grid Embed
Embeddable VibeMap component that combines the map and grid views with a toggle button. Automatically fetches places and boundary data from the VibeMap API.
Usage
Basic Embed Code
<div id="vibemap-map-grid"></div>
<script
src="https://web.vibemap.com/load.js"
data-iframe-el="vibemap-map-grid"
data-resize="true"
data-url="https://web.vibemap.com/embed/map-grid?slug=san-francisco"
></script>
URL Parameters
Give the embed a boundary or a list:
| Parameter | Type | Default | Description |
|---|---|---|---|
slug or boundary | string | - | Boundary slug, such as san-francisco. The map draws the boundary and shows what is inside it. |
list | string | - | List slug from the Hub. Uses the list's boundary, filters and theme. |
Every other parameter, from map style to card display, is in Map-Grid URL Parameters.
Example with Parameters
<div id="vibemap-sf-places"></div>
<script
src="https://web.vibemap.com/load.js"
data-iframe-el="vibemap-sf-places"
data-resize="true"
data-url="https://web.vibemap.com/embed/map-grid?slug=san-francisco&defaultView=grid&gridColumns=4&showVibesOnCards=true"
></script>
Events and Sizing
In map view the embed fills 90% of the visitor's window height, unless mapHeight sets the map's size; in grid view it grows to fit its cards. See Embedding and sizing for the height protocol, full-screen panels and Back.
The embed posts these messages to your page. All but lock-viewport carry embedId: "map-grid".
| Message | Payload | Sent when |
|---|---|---|
view-changed | { embedId, view } | The visitor switches between map and grid |
filters-changed | { embedId, data } | The visitor changes a filter |
card-clicked | { embedId, data } | The visitor clicks a card |
marker-clicked | { embedId, data } | The visitor clicks a map marker |
polygon-selected | { embedId, data: { polygonIndex } } | The visitor selects a boundary area, or clears it (null) |
resize | { embedId, height } | The embed's height changes |
lock-viewport | { lock } | A full-screen panel opens (true) or closes (false) |
Check that the slug exists before you publish: https://api.vibemap.com/v0.3/boundaries/?slug=<slug> returns one result for a real boundary.