QtMobility Reference Documentation

QML PositionSource Element

The PositionSource element allows you to get information about your current position. More...

This element was introduced in Mobility 1.2.

Properties

Signal Handlers

Methods

Detailed Description

The PositionSource element allows you to get information about your current position. You can receive information about things such as latitude, longitude, altitude, and speed. This element is part of the QtMobility.location 1.1 module.

Support for location sources are platform dependant. When declaring a PositionSource element, a default PositionSource source shall be created. Supported positioning methods are held in positioningMethod. As a development convenience, one may also set data file as a source (NMEA format). Location updates are not necessarily started automatically upon element declaration, see start stop active and update.

Here is very simple example QML to illustrate the usage:

 import Qt 4.7
 import QtMobility.location 1.1

 Rectangle {
         id: page
         width: 350
         height: 350
         PositionSource {
             id: positionSource
             updateInterval: 1000
             active: true
             // nmeaSource: "nmealog.txt"
         }
         Column {
             Text {text: "<==== PositionSource ====>"}
             Text {text: "positioningMethod: "  + printableMethod(positionSource.positioningMethod)}
             Text {text: "nmeaSource: "         + positionSource.nmeaSource}
             Text {text: "updateInterval: "     + positionSource.updateInterval}
             Text {text: "active: "     + positionSource.active}
             Text {text: "<==== Position ====>"}
             Text {text: "latitude: "   + positionSource.position.coordinate.latitude}
             Text {text: "longitude: "   + positionSource.position.coordinate.longitude}
             Text {text: "altitude: "   + positionSource.position.coordinate.altitude}
             Text {text: "speed: " + positionSource.position.speed}
             Text {text: "timestamp: "  + positionSource.position.timestamp}
             Text {text: "altitudeValid: "  + positionSource.position.altitudeValid}
             Text {text: "longitudeValid: "  + positionSource.position.longitudeValid}
             Text {text: "latitudeValid: "  + positionSource.position.latitudeValid}
             Text {text: "speedValid: "     + positionSource.position.speedValid}
         }
         function printableMethod(method) {
             if (method == PositionSource.SatellitePositioningMethod)
                 return "Satellite";
             else if (method == PositionSource.NoPositioningMethod)
                 return "Not available"
             else if (method == PositionSource.NonSatellitePositioningMethod)
                 return "Non-satellite"
             else if (method == PositionSource.AllPositioningMethods)
                 return "All/multiple"
             return "source error";
         }
     }

See also QGeoPositionInfoSource, QGeoPositionInfo, QNmeaPositionInfoSource, and QGeoCoordinate.

Property Documentation

active : bool

This property indicates whether the position source is (/should be) active. Setting this property to false equals calling stop, and setting this property true equals calling start.

This property group was introduced in Mobility 1.2.

See also start, stop, and update.


nmeaSource : url

This property holds the source for NMEA data (file). One purpose of this property is to be of development convenience.

Setting this property will override any other position source. Currently only files local to the .qml -file are supported. Nmea source is created in simulation mode, meaning that the data and time information in the NMEA source data is used to provide positional updates at the rate at which the data was originally recorded.

If nmeaSource has been set for a PositionSource element, there is no way to revert back to non-file sources.

This property group was introduced in Mobility 1.2.


position : Position

This property holds the last known positional data.

The Position element has different positional member variables, whose validity can be checked with appropriate validity functions (e.g. sometimes an update does not have speed or altitude data).

However, whenever a positionChanged signal has been received, at least position::coordinate::latitude, position::coordinate::longitude, and position::timestamp can be assumed to be valid.

This property group was introduced in Mobility 1.2.

See also start, stop, and update.


positioningMethod : enumeration

This property holds the supported positioning methods of the current source.

  • NoPositioningMethod - No positioning methods supported (no source).
  • SatellitePositioningMethod - Satellite-based positioning methods such as GPS is supported.
  • NonSatellitePositioningMethod - Non satellite methods are supported.
  • AllPositioningMethods - Combination of methods are supported.

This property group was introduced in Mobility 1.2.


updateInterval : bool

This property holds the desired interval between updates (milliseconds).

This property group was introduced in Mobility 1.2.

See also QGeoPositionInfoSource::updateInterval().


Signal Handler Documentation

PositionSource::positionChanged ()

This signal is sent when a position update has been received from the location source. Upon receiving this signal, at least position::latitude, position::longitude, and position::timestamp members of the position have been updated.

This documentation was introduced in Mobility 1.2.

See also updateInterval.


Method Documentation

PositionSource::start ()

Requests updates from the location source. Uses updateInterval if set, default interval otherwise. If there is no source available, this method has no effect.

This documentation was introduced in Mobility 1.2.

See also stop, update, and active.


PositionSource::stop ()

Stops updates from the location source. If there is no source available or it is not active, this method has no effect.

This documentation was introduced in Mobility 1.2.

See also start, update, and active.


PositionSource::update ()

A convenience method to request single update from the location source. If there is no source available, this method has no effect.

This documentation was introduced in Mobility 1.2.

See also start, stop, and active.


X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.