AnsweredAssumed Answered

get user coordinates without going to application map page

Question asked by rajni_sharma on Aug 25, 2020
Latest reply on Aug 26, 2020 by LDanzinger-esristaff

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)
            if (lastPosition !== null) {
            // update last position
            lastPosition = locationDisplay.location.position;
            // update the polyline
  "Graphic", {geometry: polylineBuilder.geometry}));
        Component.onCompleted: {
            locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeCompassNavigation;
        GraphicsOverlay {
            id: locationHistoryLineOverlay
            SimpleRenderer {
                SimpleLineSymbol {
                    color: "blue"
                    style: Enums.SimpleLineSymbolStyleDash
                    width: 5
    }//End Mapview
    PolylineBuilder {
        id: polylineBuilder
        spatialReference: SpatialReference { wkid: 4326 }