coordinates are nan for latitude and logitude
-
Hi all
Below code worked fine before.I am getting nan for latitude and longitude now.
In .pro file i have: QT += quick quickcontrols2 sql qml positioning network core
location
import QtPositioning 5.12 also i have
GPS on Android device is ON
SDK platform 30
NDK 21.3.65My main idea is to get GPS coordinates from Android device and send to database
Page { property string lat property string lon property date currentTime: new Date() property string timeString property string textString property string photoString Rectangle { id: rect1 anchors.fill: parent POST_REQ_CAMERA { id: demo } PositionSource { id: src updateInterval: 5000 active: true onPositionChanged: { var coord = src.position.coordinate; console.log("Coordinate:", coord.latitude,coord.longitude ); lat=coord.latitude; //lat=src.position.coordinate.latitude lon=coord.longitude; } } Image { id: photoPreview anchors.fill: parent fillMode: Image.PreserveAspectFit } Camera { id: camera imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash captureMode: Camera.CaptureStillImage exposure { exposureCompensation: -1.0 exposureMode: Camera.ExposurePortrait } flash.mode: Camera.FlashRedEyeReduction imageCapture { id: imageSaved onImageSaved: { //photoPreview.source = preview photoString=path //demo.processImage(preview); } } } VideoOutput { source: camera //anchors.fill: parent //focus : visible // to receive focus and capture key events when visible } Button { id: cpatureButton opacity: 0.5 Text { id: textId text: qsTr("Take Photo") color: "white" } onClicked: { camera.imageCapture.capture(); cpatureButton.enabled=false textId.visible=false sendButton.visible = true sendButton.enabled = true complainText.visible = true } } Button { id: sendButton text: "Send" visible : false enabled: false onClicked: { timeString = currentTime.toLocaleString(locale,"yyyy-MM-dd hh:mm:ss");// Locale.ShortFormat); textString = complainText.text demo.upload(lat,lon, timeString,textString, photoString) console.log(lat,lon,timeString, textString, photoString); } } TextField { id: complainText x: parent.width/2 y: parent.bottom visible : false width: 160 placeholderText: "Enter Text Here" focus: true color: "#aaa" text: lat + lon } } }
-
@Jasur
at what position in your code do you get NaN? -
@raven-worx On a huawei mobile device, after clicking on the send button, I display the lat and lon on the text field where I get the result of the nan. In below code i get nan
text: lat + lon
-
@Jasur
and this output is still ok?console.log("Coordinate:", coord.latitude,coord.longitude );
-
@raven-worx when i choose desktop kit console.log shows me coordinates, but for android kit there is no console.log output, that is why i used
text: lat + lon
to check coordinates