Hello, you can use databases to store latitude and longitude, whenever a new location is obtained, save it in the database. When you need to display the location history, collect the values obtained from the database and show them on the map.
You can store the locations in a list in the database, which will be stored in a tag, with each pair of coordinates (latitude and longitude) a unique item in the list, with a corresponding index.
In the example I’m using TinyDB, but it is an internal database on the user’s device, I suggest you use databases in the cloud.
The tag is the name that you will assign to the stored locations, you must name it according to the need, as they are vehicle locations, you can use the vehicle plate as a name for the list of its coordinates, so each vehicle will have your own list of coordinates stored in a tag according to your plate.
If you want to store according to the order, you will have more work, I suggest you create a unique “tag” for each order, and store the coordinates using the order tag.
Example:
call TinyDB store value
tag: “vehicle_locations_1” (this is the list tag)
value: latitude 1 / longitude 1 (this is the first item, receives index 1)
latitude 2 / longitude 2 (index 2, the first item receives the latitude, the second the longitude, example: 55,123456 / 78,298391)
latitude 3 / longitude 3 (index 3)
latitude 4 / longitude 4 (index 4)
latitude 5 / longitude 5 (index 5)
The “/” will be used to separate the coordinate pair.
So, to call these values, you need to create a variable that will receive the TinyDB values in LIST format:
initialize global CoordinateList: create empty list
set global CoordinateList to: call TinyDB get value
tag: “vehicle_locations_1”
When you want to get each of these values, you will need to store them in a new variable, suggestion:
initialize global CoordinatesPair: create empty list
set CoordinatesPair to: select list item list: get global
index: [1] (this is the index of the coordinate pair you are getting)
This will return a string with the coordinate pair, use the “Spli text” block to separate the coordinates in latitude and longitude.
initialize global Latitude: 0
initialize global Longitude: 0
set global Latitude to: select list item list: Split text: get global CoordinatesPair
at: “/”
index: 1
set global Longitude to: select list item list: Split text: get global CoordinatesPair
at: “/”
index: 2
Done, you have your coordinates separated again, now mark the ones on the map, it’s not difficult, research and study about the Map component of Kodular, I’m sure you will love it.
After being able to mark these coordinates on the map everything will be easy, just repeat the same process for all the coordinates you have stored. Study on the “for each” block.
If you want help with this project, I am willing to contribute, good luck and a big hug from Brazil!