Map with markers
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.
- 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 sample Airtable base 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:
This tag is used to centre the map itself and define a zoom, NOT to add a marker at this location. Use case: To display an area on the map where the centre is not necessarily where the map marker(s) are.
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
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 here.
To center the map in a specific location point, use the
<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
The [component:map:<latitude>:<longitude>:<zoom>] tag is only used to centre the map itself on the specified location, NOT to add a marker at this location.
To add any marker to the map, it's necessary to bind the map component to a list of items coming from an API (explained in the sections below).
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.
The size of the marker icon in the map will be proportional to the size of the top-level component it's placed in on the design file (the one with the Bravo tag).
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
Zoomfeatures as shown below.
The map does not refresh automatically to center it in the user's location. However, you can send the user's location using location variables and setting up a request against a service called HTTPbin. 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.
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.
We'll set up a list request 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.
To bind the data fetched with this list request, open the
Map Markercomponent shown below. Then, we'll need to bind a list of markers to the
Pointsproperty. 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,
Longitude, to their corresponding data items.
Finally, to bind the data for the detail page, we'll need a detail request 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.
Now, you'll be able to preview the map with the markers on Bravo Vision!