Prepare app for geojson data adding

With all information discussed, it’s time to start working with the plugin
Due to how Mapbox and Bubble work separately they have quite a specific way to work together.
But nothing to worry about! Everything is pretty simple and straight forward when you get the hang of it.
We’ll considered that you already have your database set up and have the map ready and begin from there.
If you haven’t done that already you can learn how to do that in and .
Preparation
To prepare the app with the ability to add any element on the map and save it into bubble database, we will need input fields for the data (coordinates and image) and a button that starts a workflow, triggering the actions.
In this example we will use simple input fields for coordinates, a dropdown menu to choose the marker image and 3 buttons to add a marker, a line and a polygon.
Note: You are free to use any way to input the data in actions and any way to trigger those actions. This tutorial is one example to get you to know how the actions work and in what order they need to be triggered in.
Tutorial
First we will set up all the needed inputs and buttons:
paveikslas.png
Every button text and input description talks for themselves.
For this example we use:
● Simple inputs for coordinates or colors
● Dropdown menu to choose the image for the marker with there options:
paveikslas.png
● A special input for polygon fill to only allow decimals from 0 to 1:
paveikslas.png
● 3 buttons to add each element.
Next we’ll add 2 images straight into the database, to be able to choose one of them for the markers:
paveikslas.png
Now we’ll start the main part: workflows!
Create an event for each button:
paveikslas.png
In each event we’ll add 2 actions - one to take data from inputs and create a copy of the element in the database and the other to add that element onto the map.
First we start with a marker, add 2 actions, one to create a marker with input values and the other to draw marker on the map, you can find the custom actions of the plugin under “element actions”:
paveikslas.png
On step one, add all the values taken from input fields into the marker creation:
paveikslas.png
We are using a fixed title, but you can also have a dynamic value there.
On step 2, where the marker is actually added on the map, we’ll insert values from the result of marker’s creation:
paveikslas.png
It is important to use the unique ID of the marker as the map marker’s ID, to be able to link them together later for deletion or any other use case inside the bubble app. Currently there is no other way to link database values to elements of the map.
We repeat the same things for polygons and lines:
Line actions:
paveikslas.png
Line creation in the database and line addition to the map:
paveikslas.png
paveikslas.png
Polygon actions:
paveikslas.png
Polygon creation in the database and addition to the map:
paveikslas.png
paveikslas.png
And that’s it! as long as you have the element’s creation in the database and addition to the map right next to each other and set up in this way, you’re good to go!
Let’s try adding something to the map:
We’ll add a marker with chosen image in the coordinates of [0,0]:
paveikslas.png
After pressing the “Marker image” button a marker appears on the map with our set values:
paveikslas.png
Also the marker is added in the database:
paveikslas.png
Let’s try adding a line:
paveikslas.png
We fill the appropriate input fields with the needed info
NOTE: there is currently no error handling, so the coordinates have to be written in the exact way shown in the picture, being 2 numbers inside [] separated by commas like shown in the picture. The color also has to be written exactly in a HEX color of the code (unless you use a plugin that does that for you). If these values are incorrect, they will be saved in bubble database and you’ll get a pop up error each time you reload the page, also the element will not appear.
After pressing “add line” button we can see a line appears with chosen coordinates and color:
paveikslas.png
Same with polygons, insert values:
paveikslas.png
After pressing “Add polygon” we see a polygon appears on the map and is saved in the database:
paveikslas.png
Now you know how to add save and store data using coordinates!
Your next step is to learn how to use the map’s interactive menu to add or draw everything yourself on the map, no numbers!
Next recommended step -
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.