01-20-2013 09:47 PM
Using the QML PositionSource that is a part of Qt Mobility 1.2 but keep getting an "module "QtMobility.location" is not installed" . At the top of my main.qml page i have "import QtMobility.location 1.2" but not sure what else i need to do at this point.
Any ideas? I'm a total rook at developing so the more info the better..
Solved! Go to Solution.
01-21-2013 04:00 AM
01-21-2013 01:32 PM
that worked! however, is there anything else i need to do to initialize the gps?
is positionSource.start() within the onButtonClicked {} the correct way? i'm attempting to start the gps and on an interval update the position then use the coordinate.distanceTo() function to calculate distance traveled.
01-22-2013 03:20 AM
02-26-2013 02:24 PM
02-26-2013 06:20 PM
Hi,
The QML PositionSource, Position, and Coordinate elements are supported, including the Coordinate's distanceTo() method.
Jim
02-26-2013 06:27 PM
Hi,
jvaldezp, do you mean beta NDK 10.1? The QtMobilitySubset.location qml plugin should be available. Note that you don't need to add LIBS + =-lQtLocationSubset to your .pro file if you are just using the QML location elements. But you do need the access_location_services permission in the bar descriptor file.
Jim
02-27-2013 09:00 AM
certainly is what I read in the documentation, but when running the application it does nothing, the screen stays black., try running the following code I found on the forum, I additionally QtMobilitySubset.location indicates that the module is not installed or unknown library QtMobilitySubset.location.
02-27-2013 02:43 PM
Hi,
I tried that qml without luck, even with some reworking. There may be other issues with it. Here's is a sample that works for me:
/* Copyright (c) 2012 Research In Motion Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Importing all our cascades functions. import bb.cascades 1.0 import QtMobilitySubset.location 1.1 Page { id: mainPage // A container is used to gather visual items together. Container { // A DockLayout is applied to the main container, this makes it // possible to layout controls and view inside the container. layout: DockLayout { } attachedObjects: [ TextStyleDefinition { id: tsd base: SystemDefaults.TextStyles.BodyText fontSize: FontSize.XSmall }, PositionSource { id: positionSource updateInterval: 1000 active: true }, Coordinate { id: startCoord latitude: 44.48197262 longitude: -80.2411541 altitude: 340 } ] // The container containing the bubble image and text. Container { id: positionInfo layout: StackLayout { } Label { text: "<==== PositionSource ====>" textStyle { base: tsd.style } } Label { text: "positioningMethod: " + positionInfo.printableMethod(positionSource.positioningMethod) textStyle { base: tsd.style } } Label { text: "nmeaSource: " + positionSource.nmeaSource textStyle { base: tsd.style } } Label { text: "updateInterval: " + positionSource.updateInterval textStyle { base: tsd.style } } Label { text: "active: " + positionSource.active textStyle { base: tsd.style } } Label { text: "<==== Position ====>" textStyle { base: tsd.style } } Label { text: "timestamp: " + positionSource.position.timestamp textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.latitudeValid ? positionSource.position.coordinate.latitude : "--" return "latitude: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.longitudeValid ? positionSource.position.coordinate.longitude : "--" return "longitude: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.horizontalAccuracyValid ? positionSource.position.horizontalAccuracy : "--" return "horizontal accuracy: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.altitudeValid ? positionSource.position.coordinate.altitude : "--" return "altitude: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.verticalAccuracyValid ? positionSource.position.verticalAccuracy : "--" return "vertical accuracy: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = positionSource.position.speedValid ? positionSource.position.speed : "--" return "speed: " + outStr } textStyle { base: tsd.style } } Label { text: { var outStr = (positionSource.position.latitudeValid && positionSource.position.longitudeValid ) ? positionSource.position.coordinate.distanceTo(star tCoord) : "--" return "distance to start: " + outStr } textStyle { base: tsd.style } } 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"; } } } }
You can get this to work with a project based on the default empty project template in the Momentix IDE (File -> New -> Project... -> BlackBerry Project -> Cascades Application -> Standard empty project) simply by replacing the content of the project's main.qml file with the code above. Also, you must add location permission to the bar-descriptor.xml file:
<permission>access_location_services</permission>
And make sure Location Services is enabled on device (Settings -> Location Services)
Hope this helps,
Jim
02-27-2013 04:13 PM
Hi Jim, thanks again., I do not know what happens ... create a new project, copy your code, in addition to the bar descriptor.xml have permission ... but not run, this is my version of the QNX ® Momentics ® IDE for BlackBerry ® 10 Native SDK Version: 10.1.0, I was reading and says that this plugin is not available for qml ...