QML GPS
-
Hi, I am totally new to Qt symbian.
May I ask how can I get GPS location data (longitude, latitude) in qml?
Thank You.
-
Take a look at "mobility":http://doc.qt.nokia.com/qtmobility/qml-location-plugin.html.
-
I have use the following code to get GPS location latitude and longitude.
It seems work well in simulator Qt creator, but when I put it in phone it show "NaN".
May I know what is the problem?@import QtQuick 1.1
import QtMobility.location 1.2Rectangle {
id: page
width: 350
height: 350
PositionSource {
id: positionSource
updateInterval: 1000
active: true
}
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";
}
}
@ -
Are you sure the GPS has locked? Maybe you just need to wait a minute or two for it to see the satellites. It's just a guess, though, I've never used QtMobility.
-
Yeah I have wait for 5 minute already..
The result come out as below :
<====PositionSource====>
positioningMethod :Satellite
nmeaSource:
updateInterval:1000
active:true
<====Position====>
latitude:NaN
longitude:NaN
altitude:NaN
speed:-1
timestamp: Invalid Date
altitudeValid: false
longitudeValid: false
latitudeValid: false
speedValid: false -
And does it work in any other app?
-
Sorry I have never try this in other apps. This is the first time I am trying to get GPS location data.
-
I meant does GPS work in other apps, not necessarily written by you ;)
-
Yes. I think because I am getting this code from other website.
http://www.qtcentre.org/threads/41513-Get-GPS-Position-with-QML
-
Hi amccarth,
I have put in below code inside the .pro file but it still cannot run.
symbian:TARGET.CAPABILITY += NetworkServices Location
CONFIG += mobility
MOBILITY += location