It's strangely hard to find any documentation on accessing geolocation information for Ubuntu Touch specifically and even Qt5 more generally. The Qt Mobility APIs provided this in Qt4, and they seem to have been split into separate libraries in Qt5. These libraries were apparently removed from the Qt 5 distribution and are now considered optional add-on modules. As they are now "add-ons," the Qt website doesn't seem to publish their documentation anymore. There are Ubuntu packages for them, but installing the SDK doesn't actually pull them in. So it is unclear if they will be available on the phone or not.
The correct package seems to be qtdeclarative5-qtlocation-plugin , which can be accessed in Qml with import QtLocation 5.0
Trying to simply get latitude and longitude has been an exercise in futility. Looking at older Qt4 docs, I tried:
import QtQuick 2.0
import QtLocation 5.0
PositionSource {
id: src
updateInterval: 1000
active: true
onPositionChanged: {
var coord = src.position.coordinate;
console.log("Coordinate:", coord.longitude, coord.latitude);
}
}
Sadly, this just segfaults...
So my question, simply stated, is how can you access geolocation information on Ubuntu Touch in Qml?
I think it did not work for you due to GPS not being enabled on the device. The following code sample worked without segfaulting on my laptop. On the device, it takes about 1-2 mins to get the GPS lock since AGPS hasn't landed yet.