View on GitHub Sample viewer app

This sample demonstrates how to parse NMEA sentences and use the results to show device location on the map.

Image of display device location with nmea data sources

Use case

NMEA sentences can be retrieved from GPS receivers and parsed into a series of coordinates with additional information. Devices without a built-in GPS receiver can retrieve NMEA sentences by using a separate GPS dongle, commonly connected via bluetooth or through a serial port.

The NMEA location data source allows for detailed interrogation of the information coming from the GPS receiver. For example, allowing you to report the number of satellites in view.

How to use the sample

Click floating button “Play” to parse the provided NMEA sentences into a location data source, and display the location position and related satellite information. Click “Stop” to stop displaying the location information. The sample will automatically re-center the location data source as it moves across the map.

How it works

  1. Load NMEA sentences from a local file.
  2. Parse the NMEA sentence strings, and push data into NmeaLocationDataSource.
  3. Set the NmeaLocationDataSource to the LocationDisplay’s data source.
  4. Start the location display to begin receiving location and satellite updates.

Relevant API

  • LocationDisplay
  • NmeaLocationDataSource
  • NmeaSatelliteInfo

About the data

This sample reads lines from a local file to simulate the feed of data into the NmeaLocationDataSource. This simulated data source provides NMEA data periodically, and allows the sample to be used on devices without a GPS dongle that produces NMEA data.

The route taken in this sample features a one minute driving trip around Redlands, CA.

Tags

GPS, history, navigation, NMEA, real-time, trace

Sample Code

DownloadActivity.kt DownloadActivity.kt MainActivity.kt
/* Copyright 2022 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources
import android.content.Intent
import android.os.Bundle
import com.esri.arcgismaps.sample.sampleslib.DownloaderActivity
class DownloadActivity : DownloaderActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
downloadAndStartSample(
Intent(this, MainActivity::class.java),
// get the app name of the sample
getString(R.string.display_device_location_with_nmea_data_sources_app_name),
listOf(
// ArcGIS Portal item containing the Redlands.nmea
// which features a vehicle driving around southern Redlands, CA.
"https://www.arcgis.com/home/item.html?id=d5bad9f4fee9483791e405880fb466da"
)
)
}
}