View on GitHub Sample viewer app
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

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 “Start” 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
    .
  3. Set the
    to the
    ’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

. 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.

Additional information

To learn more about using the ArcGIS Maps SDK for Java for retrieving NMEA sentences from a GPS dongle, see the Esri Community blog post Adding GPS data to your ArcGIS Runtime API for Java App.

Tags

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

Sample Code

module-info.java module-info.java DisplayDeviceLocationWithNmeaDataSourcesController.java DisplayDeviceLocationWithNmeaDataSourcesSample.java
/*
* 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.
*/
module com.esri.samples.display_device_location_with_nmea_data_sources {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.display_device_location_with_nmea_data_sources to javafx.fxml;
exports com.esri.samples.display_device_location_with_nmea_data_sources;
}