Display device location with NMEA data sources

View inQMLC++
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.

screenshot

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

Tap "Start" to parse the NMEA sentences into a simulated location data source, and initiate the location display. Tap "Reset" to reset the location display.

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 location display's data source.
  4. Start the location display to begin receiving location and satellite updates.

Relevant API

  • LocationDisplay
  • NMEALocationDataSource

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

DisplayDeviceLocationWithNmeaDataSources.qmlDisplayDeviceLocationWithNmeaDataSources.cppDisplayDeviceLocationWithNmeaDataSources.h
                                                    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// [WriteFile Name=DisplayDeviceLocationWithNmeaDataSources, Category=Maps]
// [Legal]
// Copyright 2021 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.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0

Item {

    // add a mapView component
    MapView {
        id: view
        anchors.fill: parent
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    DisplayDeviceLocationWithNmeaDataSourcesSample {
        id: model
        mapView: view
    }

    Button {
        id: button
        anchors {
            horizontalCenter: parent.horizontalCenter
            bottom: parent.bottom
            margins: 25
        }
        width: 200
        text: model.nmeaSimulationActive ? "RESET" : "START"
        onClicked: {
            model.nmeaSimulationActive = !model.nmeaSimulationActive;
            if (model.nmeaSimulationActive)
                model.start();
            else
                model.reset();
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.