-
Notifications
You must be signed in to change notification settings - Fork 0
Frontend

The following function loads the GeoJSON data for all maps on the home screen. It utilizes the Thunkable block 'addGeoJSON' to fetch data from a cloud variable stored in Firebase Realtime Database.


This code snippet contains a simple algorithm to calculate parking lot capacities during testing. The function calculateCapacity updates the capacity cloud variable of each lot using the 'hotMeterBar_mapV' for user input, employing a scoring system where:
'Low' updates capacity by -1. 'Medium' by +1. 'Full' by +2.

The function changeColorJSON compares the current lot capacity cloud variable to the max capacity of the lot and updates the GeoJSON color accordingly:
Green if capacity is less than 70% of the max capacity. Yellow/orange if it's greater than 70%. Red if it's equal to or greater than the max capacity.


This code adds a marker on the map to indicate successful parking with a popup alert. It uses Thunkable's 'Location Sensor' block to retrieve the user's coordinates and stores them in a local variable. The function addParkedMarker then utilizes Google Maps API to add a marker with the given coordinates with Thunkable's 'addMarker' block.



The 'LeaveBTN_mapV' triggers functions leavingMarkerCoordinates and updateLeavingMarkers. leavingMarkerCoordinates saves the coordinates of the user leaving in a cloud function, while updateLeavingMarkers displays the location of the last 5 users leaving by adding markers on the map.

'leavingMarkerCoordinates' simply saves the coordinates of the user leaving in a cloud function, under the 'leavingMarkers' object. This will be used to display the markers in the map of user's that are looking for parking.

'updateLeavingMarkers' displays the location of the last 5 users that indicated that are leaving. It uses a loop to call the 'addIconMarker' function, and it retrieves the coordinates for the markers from the cloud.


The following snippet of code updates the parking history list in the screenshot above. It uses a loop to retrieve the 'display' variable from the cloud and stores it in a list.

The following chuck of code updates the list in the cloud. This function creates an object under Users/'userID/history/'count' with the following fields:
'display': this is the title displayed in the history list. 'parked': the time the user parked at. 'left': the time the user left. 'date': the date the user parked. 'lot': the lot the user parked at. 'coordinates': the coordinates used to add the marker on the history map.

When a history list item is clicked, the function updateHistoryMap shows a map with a marker indicating where the user parked. It retrieves the necessary variables and uses Thunkable's 'addMarker' block to add the marker.

--