0

I'm new to both C++ and BB10 development (Cascades), and have been having a difficult time learning Blackberry's semi-implementation of Qt's QML.

I have an app I'm working on and I'd like to get the phone's Latitude, Longitude, and other address related information (City, State, Country, etc). I've tried a few different things, like registering existing C++ classes to be called from QML, but certain things aren't available in the BB10 version of the libraries.

I found that the QtMobilitySubset.location 1.2 library available in Cascades offers PositionSource and Address objects, however I have been unable to get any data from them.

I've included them in the "attachedObjects" portion of the QML document:

attachedObjects: [
    PositionSource {
        id: positionSource
        updateInterval: 5000
        active: true  
    },
    Place {
        id: place
    },
    Address {
        id: address

    }

]

and then tried getting information from address by calling address.state but get an empty value. Same goes for positionSource.position.coordinate.longitude -- no value.

I've tried looking at other examples provided by Blackberry, but haven't been able to identify what I'm doing wrong.

Does anyone know of an example which demonstrates using pure QML to get location information?

dmux
  • 442
  • 7
  • 24
  • I know I'm not helping, but to be honest I suggest you use c++ for these things. It gives you more control and just works a lot better. Then just change QML UI from c++ – Bojan Kogoj Jan 10 '15 at 23:45
  • What gives you the idea the Place and Address would magically do reverse geocoding for you? They don't. – onion Jan 13 '15 at 16:33

1 Answers1

0

In your qml file import QtMobilitySubset.location 1.1, in your pro file add LIBS += -lQtLocationSubset -lbbcascadesmaps -lGLESv1_CM and in your bar descriptor.xml make sure you have ticked location and internet in application tab, also make sure your location services are turned on in device. The below code prints the latitude and longitude on the button click.

Container {
    id:mainContainer
    property string longitude
    property string latitude
    property variant cord


Button:{
text: "Show"
onClicked:
  {
   console.log("actual latitude:"+latitude+" actual longitude:"+longitude);
  }
}

attachedObjects:[
PositionSource{
            id: locationPos
            updateInterval: 1000

            onPositionChanged: {
                cord = locationPos.position.coordinate;
                longitude = cord.longitude;
                latitude = cord.latitude;
            }

        }

]


   onCreationCompleted: {
        locationPos.start();
    }
}
Francis F
  • 3,157
  • 3
  • 41
  • 79