Record NMEA
This example demonstrates how to build a Flutter app using the Maps SDK to record data including NMEA Chunks and export the log as a CSV file.
This example is supported only on Android, as the NMEA Chunk data type is exclusive to this platform. On iOS, a warning will be displayed, and this data type will not be available.
How It Works
The example app highlights the following features:
- Initializing a map.
- Configuring the map to use live data from the device's GPS.
- Specifying custom device information
- Starting and stopping a recording and exporting the log as a CSV file.
UI and Map Integration
The following code builds the UI with a GemMap
widget and an app bar that includes buttons for starting/stopping recording and following the user's position.
Requesting Location Permission
The following code centers the camera on the user's current position if location permission is granted. Otherwise, it requests the necessary permission.
The Permission.manageExternalStorage
is also required for saving the exported file to a custom user location.
Starting and Stopping Recording
Exporting the log as a CSV file
This code loads the last recorded track from device memory, exports the log as a CSV file and lets the user decide where to save the file. The CSV file can later be opened by the user with a specialized application.
Provide Device Information
The device_info_plus
package can be used to get hardware details about the device. Other packages (such as battery_plus
) can be used to get more hardware details.
Populate the map as needed. This map can be used within the RecorderConfiguration
class passed to the Recorder
.
Utility Functions
The getDirectoryPath
function retrieves the root directory path for the app and returns the desired directory path inside the "Data" folder.
- Android
Add the following code to the android/app/src/main/AndroidManifest.xml
file, within the <manifest>
block:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
This example uses the Permission Handler package. Be sure to follow the setup guide.