Position display

Geographic position can be incorporated into your app in a number of ways:

  • Show device location either on a map or as coordinates displayed in the user interface.
  • Store device location as coordinates in a file for later use (for example, tracklog).

Qt Quick contains a PositionSource component, which forms the fundamental building block for working with positions in ArcGIS Runtime SDK for Qt. If your application doesn't need to display positions in a map, use the Qt Quick PositionSource component in your app, and display the coordinates in the user interface as text or store them in a file. When you want to show your location on a map, Esri have supplied two choices:

  • The map's positionDisplay property
  • The PositionLayer component

The map's positionDisplay property is the primary location display choice for your app. Similar to a map grid, position display reacts to map panning and rotation. There is only one position display in your map. If you want to show locations from multiple sources, such as showing current location from your device along with a prerecorded tracklog, you can add the additional source positions using position layers.

The position display is always the topmost layer of the map and can autopan the map as the current location changes. It has fewer properties than a position layer for modifying the symbology used for the location, but is more closely integrated with the map behaviour.

The syntax for adding position display to your map is as follows:

positionDisplay {
        positionSource: positionSourceNMEA
    }

    PositionSource {
        id: positionSourceNMEA
        nmeaSource: "GPS.txt"
    }

A position layer displays a chosen location on a map. Location can be deduced from any number of sources, most commonly a GPS or location sensor inside, or connected to, your device. Location can also come from a local text file or a feed of locations such as a network stream.

Along with the map's built-in position display, multiple position layers can be defined in a map, allowing you to display location results from different sources. This is great if you need to track multiple field-workers in your project team, or compare results from different sensors.

Unlike the position display, a position layer will not automatically pan the map when the current location changes.

The following example adds a position layer to a map, displaying the contents of the text file GPS.txt, updating the position on the screen each second. In this example no trail or track points are shown, and a custom symbol is used for the location.

PositionLayer {
        showTrackPoints: false
        showTrail: false
        locationSymbol: mySymbol

        PositionSource {
            nmeaSource: "GPS.txt"
            updateInterval: 1000

            onPositionChanged: {
                myPosition.x = position.coordinate.longitude;
                myPosition.y = position.coordinate.latitude;
                myPositionChanged();
            }
       }
   }