Position/location Point Display in QML

670
4
10-08-2018 10:37 AM
GiatriLalla
New Contributor III

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)
            }
            }
        }

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
4 Replies
HeathcliffRongo
New Contributor III

I can't see where "mapView" is defined in your sample code. Is it defined in your actual code? 

0 Kudos
GiatriLalla
New Contributor III

I think its suppose to be MapView*

0 Kudos
GiatriLalla
New Contributor III

It is, however unintentionally. This problem was re-worded as well as the code was changed and posted in the forum as another question.

0 Kudos