Skip to content

Manual Push NMEA Position

In this guide you will learn how to set or push one individual NMEA position, or sentence, at a time, to gain a good understanding of how navigation and simulation work at a low level.

NMEA text sentence position

NMEA text sentence position

First, get an API key token, see the Getting Started guide.

Qt should be installed to continue.

The Maps SDK for Qt should be installed, see the Setup Maps SDK for Qt guide.


ManualPushPosition demonstrates how easy it is to push one NMEA sentence (position) at a time, to set the live position tracker there.

How it works

In Qt, go to the File menu and select Open File or Project…

then browse to the ManualPushPosition example folder and open

You may want to have a look at Setting your API Key to see how to open and configure a project and set your API Key.

In main.qml, in the Component.onCompleted: block, the datasource is set to live, and the first NMEA sentence (a line of text in one of the NMEA protocols) is pushed, so that the example starts at the first position in the NMEA set.

1ServicesManager.dataSource.type = DataSource.Type.Live;

The NMEA sentences, or positions, one per line of text, used in this example are in the cyclecounter.h header file for simplicity. They could also be in a text file on disk, or received from the network, this makes no difference.

Also the content type that will be downloaded upon demand is specified:

let updater = ServicesManager.contentUpdater(ContentItem.Type.RoadMap);

The MapView displaying the interactive map has 2 text lines at the top. The top line shows the frames per second, and the second line shows the longitude and latitude of the current position, in degrees.

The button at the bottom shows the NMEA sentence number, followed by the actual NMEA sentence itself corresponding to the current position. Click the button to push the next NMEA sentence.

 1MapView {
 2    id: mapView
 3    anchors.fill: parent
 4    viewAngle: 25
 5    zoomLevel: 69
 6    viewPerspective: MapView.ViewPerspective.View3D
 7    buildingsVisibility: MapView.BuildingsVisibility.Show3D
 8    detailsQualityLevel: MapView.DetailsQualityLevel.Medium
 9    gestures: MapView.Gesture.Pan
10              | MapView.Gesture.PanEnableVelocity
11              | MapView.Gesture.Pinch
12              | MapView.Gesture.Rotate
13              | MapView.Gesture.Tilt
14    ColumnLayout {
15        anchors.left: parent.left
17        Text {
18            text: "FPS: " + fpsCounter.fps
19        }
20        Text {
21            id: mycoord
22        }
23    }
24    ColumnLayout {
25        anchors.left: parent.left
26        anchors.bottom: parent.bottom
27        Button {
28            id: cycleButton
29            text: myCycleCounter.countCycle + ", " + myCycleCounter.nmeaSentence + " " + " - click for next position"
30            onClicked: {
31                let coordinates = mapView.wgsForScreen((mapView.width / 2), (mapView.height / 2));
32                mycoord.text = "Lon, Lat: " + coordinates.longitude + ", " + coordinates.latitude;
33                myCycleCounter.countCycle += 1;
34                console.log("Push NMEA sentence " + myCycleCounter.countCycle + ", " + myCycleCounter.nmeaSentence);
35                ServicesManager.dataSource.pushNMEASentence(myCycleCounter.nmeaSentence);
36            }
37        }
38    }

QML Examples

Maps SDK for Qt Examples can be downloaded or cloned with Git