Map with markers
Last updated
Was this helpful?
Last updated
Was this helpful?
Show a place or a list of places in a map as markers, and bind those markers to a detail page! With the Map with Markers component, apps can display a map showing real locations in it.
You'll need:
A .
Marker data, which should be a list of items containing, at least, a name and coordinates (latitude and longitude numeric values). You can replicate our to get started.
To create the interactive map:
To create the map as a fixed image with the markers, not movable or zoomable:
To specify statically the centre of the map and the zoom value:
To require location permissions to the user in a certain app screen (place the tag in the top-level app page):
To create a custom marker:
To add a map component in the design file, create a rectangle element and add the tag [component:map:interactive]
to it. This element will show a map in the app after importing it to Bravo. In case you want the map to be a fixed image with all the markers (not movable or zoomable), add just [component:map]
.
To center the map in a specific location point, use the [component:map:<latitude>:<longitude>:<zoom>]
or [component:map:interactive:<latitude>:<longitude>:<zoom>]
tags. <latitude>
and <longitude>
are the map center's coordinates. <zoom>
needs to be a number from 0 (zoomed out) to 22 (zoomed all the way in). These values can also be bound to API data, as we'll show in the next section. To do that, do not specify any of the values in the tag, use just [component:map]
or [component:map:interactive]
.
It is possible to customize how the map markers will look in the map when using the app. To do that, create a page-level component and add the tag [asset:marker:default]
to it. Inside it, you can insert an SVG component or a PNG image with a transparent background.
In case you want to show more data when a user clicks on the marker, you can bind a detail page to the map component. To do this, add a separate app page to the design file, and create a prototyping link from the map component to the screen.
Once the design file is ready, import it into Bravo to bind it to the list of markers. The map component will be displayed in the Data Binding section, with some bindable properties.
As mentioned earlier, it is possible to center the map in a location point when the user opens the screen containing it. To do this, click on the map component and bind the Latitude
, Longitude
and Zoom
features as shown below.
To display the markers in the map, it's necessary to bind the map component to a list of items coming from an API. These items must, at least, contain the following properties for each of the markers: latitude value, longitude value and name.
To bind the data fetched with this list request, open the Map Marker
component shown below. Then, we'll need to bind a list of markers to the Points
property. This data item must be a list, containing all the marker data.
After binding the list, we'll bind the individual properties of each marker, Name
, Latitude
and Longitude
, to their corresponding data items.
Now, you'll be able to preview the map with the markers on Bravo Vision!
If you need to use device location in the app (to center the map in that location, for instance), add the [require:location]
tag in the app page layer. This will ask the user to share their location with the app when opening that screen. More on location variables .
The map does not refresh automatically to center it in the user's location. However, you can send the user's location using and setting up a request against a service called . You can bind that request to the center location properties (latitude and longitude) as shown below. This way, the map will be centered on the user's location the first time it is opened.
We'll set up a in the Data Collections section. This request will obtain a list with all the markers from the backend. You've got a sample Airtable base with marker data at the end of this guide.
Finally, to bind the data for the detail page, we'll need a returning a single item from the marker list. In case you use our sample Airtable base, and use the import wizard in the Data Collections section, this request will already be set up for you. Once the request is created, we can bind the data to the detail page.