AnsweredAssumed Answered

Position/location Point Display in QML

Question asked by glalla_uwi2017 on Oct 8, 2018
Latest reply on Oct 10, 2018 by glalla_uwi2017

Good Day,

How can I get a position/location point from the locationDisplay? I want to get that point. I am using the code below but I nothing happens when I click the button.

 

import QtQuick 2.7
import QtQuick.Controls 2.1
import QtPositioning 5.3
import QtSensors 5.3
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.2
App {
    id: window
    visible: true
   
    //Create MapView that contains a Map
    MapView {
        
        anchors.fill: parent
    
        //Nest the Map as a child of the MapView
        Map {
 
    //Nest the ArcGISTiledLayer to add it as one of the Basemap's baselayers
            ArcGISTiledLayer {
                url: "https://services.arcgisonline.com/arcgis/rest/services/Polar/Antarctic_Imagery/MapServer"
            }
        }
            locationDisplay {
                positionSource: PositionSource {
                    id: ps
                }
            }
        onStatusChanged: {
            if (loadstatus === Enums.MapStatusReady) {
                ps.active = true;
            }
        }
            }
     
        Button {
            anchors {
                left: parent.left
                top: parent.top
                margins: 10
            }
            text: "get point"
            onClicked: {
                var point = mapView.locationDisplay.mapPoint;
                console.log("x", point.x, "y", point.y, "wkid", point.spatialReference.wkid)
            }
            }
        }

Outcomes