This extension is able to run in the background while your app is closed and stores location data (latitude, longitude and optionally current datetime, altitude, accuracy, speed, current address and provider) in TinyDB.
Also a background web functionality is available which can be used to send the location data in the background to a web service of your choice using a web request. This could be used for example to store the location data in a MySQL database or to send an email after a location change was detected while the app is not running.
A notifier will be displayed while the location service is running in the background.
The extension can be used for devices starting from Android 5 (API 21).
For details, example project and documentation see here App Inventor Extensions: Location Service | Pura Vida Apps
In the example app you can define a tag for TinyDB to store the data for a trip before starting the service. Later or even while the service is still running you can choose one of the tags and display the coordinates in a map. I have chosen the line string component here in the example app.
12 USD, Payment options see my webpage