HI i want to get user location coordinates without going to its map page like this link i followed. It works only on map page
Get the path covered by user and display current location
So that i can show user history on map even when it switched to any other page of application.
Is their any way so that even when a user is not on map page my app get its coordinates.
This is the code i edited for map page only.
import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.6
Rectangle {
id: rootRectangle
clip: true
width: 800
height: 600
readonly property int initialZoomScale: 8000
property bool trackingEnabled: false
property Point lastPosition: null
// add a mapView component
MapView {
anchors.fill: parent
Map {
BasemapDarkGrayCanvasVector {}
}
// set initial viewpoint near UCLA, Los Angeles
ViewpointCenter {
Point {
x: -13185535.98
y: 4037766.28
}
targetScale: initialZoomScale
}
Button {
id: button
text: trackingEnabled ? "Stop tracking" : "Start tracking"
anchors.horizontalCenter: parent.horizontalCenter
width: 200
onClicked: trackingEnabled =! trackingEnabled
}
// if tracking is enabled then show location history
locationDisplay.onLocationChanged: {
if (!trackingEnabled)
return;
if (lastPosition !== null) {
polylineBuilder.addPoint(lastPosition);
}
// update last position
lastPosition = locationDisplay.location.position;
console.log(JSON.stringify(lastPosition.json));
// update the polyline
locationHistoryLineOverlay.graphics.append(ArcGISRuntimeEnvironment.createObject("Graphic", {geometry: polylineBuilder.geometry}));
console.log(JSON.stringify(polylineBuilder.geometry.json.paths));
}
Component.onCompleted: {
locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeCompassNavigation;
locationDisplay.start();
}
GraphicsOverlay {
id: locationHistoryLineOverlay
SimpleRenderer {
SimpleLineSymbol {
color: "blue"
style: Enums.SimpleLineSymbolStyleDash
width: 5
}
}
}
}//End Mapview
PolylineBuilder {
id: polylineBuilder
spatialReference: SpatialReference { wkid: 4326 }
}
}
Solved! Go to Solution.
AppStudio is based on 5.13 I believe, so you'll need to import an older version. Since I'm not sure which version of Qt maps to which version of QtPositioning, I'd try decreasing until you find a version that works For example, try importing version 5.13.
As for how to stop it, you can call the stop method on PostionSource - PositionSource QML Type | Qt Positioning 5.15.0
I get this link Position display—ArcGIS Runtime SDK for Qt | ArcGIS for Developers Is their any example for recording. tracklog etc
You can use Qt's PositionSource type. The LocationDisplay is simply used to display the location on the map. If you just want to get the position from the device, PositionSource will do that for you.
PositionSource {
Component.onCompleted: start();
onPositionChanged: console.log("position changed", position.coordinate)
}
It gives me error
module \"QtPositioning\" version 5.15 is not installed" so i import 5.11 version
I am using arcgis appstudio version 4.2
Query 1: Plus i want this to be happen on when user sign in on my property, so i will do that but how to put it in if condition to start on login if condition checking and how to stop it. like if user sign-out from the property. I will use the code on sign on click but how to stop on sign-out btn click
AppStudio is based on 5.13 I believe, so you'll need to import an older version. Since I'm not sure which version of Qt maps to which version of QtPositioning, I'd try decreasing until you find a version that works For example, try importing version 5.13.
As for how to stop it, you can call the stop method on PostionSource - PositionSource QML Type | Qt Positioning 5.15.0