How to get position display point in QML

7615
1
Jump to solution
08-14-2015 07:09 AM
KK2014
by
New Contributor III

Hi ,

I Can display my position from map like below code from QML .But how can I get position point form positionDisplay because I want to get that point and use in buffering geometry in my application.

   positionDisplay {

            positionSource: PositionSource {

     }

        }

Thanks.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

KK-

Please see the PositionDisplay API Reference- ArcGIS Runtime SDK for Qt QML API: PositionDisplay Class Reference

It has a property on it called mapPoint, and that returns a Point object of your current location.

For example:

import QtQuick 2.3
import QtQuick.Controls 1.2
import ArcGIS.Runtime 10.26
import QtPositioning 5.3


ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "d"


    Map {
        id: map
        anchors.fill: parent


        focus: true


        positionDisplay {
            positionSource: PositionSource {
                id: ps
            }
        }


        onStatusChanged: {
            if (status === Enums.MapStatusReady) {
                ps.active = true;
            }
        }


        ArcGISTiledMapServiceLayer {
            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
        }
    }


    Button {
        anchors {
            left: parent.left
            top: parent.top
            margins: 10
        }
        text: "get point"
        onClicked: {
            var point = map.positionDisplay.mapPoint;
            console.log("x", point.x, "y", point.y, "wkid", point.spatialReference.wkid)
        }
    }
}














View solution in original post

1 Reply
LucasDanzinger
Esri Frequent Contributor

KK-

Please see the PositionDisplay API Reference- ArcGIS Runtime SDK for Qt QML API: PositionDisplay Class Reference

It has a property on it called mapPoint, and that returns a Point object of your current location.

For example:

import QtQuick 2.3
import QtQuick.Controls 1.2
import ArcGIS.Runtime 10.26
import QtPositioning 5.3


ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "d"


    Map {
        id: map
        anchors.fill: parent


        focus: true


        positionDisplay {
            positionSource: PositionSource {
                id: ps
            }
        }


        onStatusChanged: {
            if (status === Enums.MapStatusReady) {
                ps.active = true;
            }
        }


        ArcGISTiledMapServiceLayer {
            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
        }
    }


    Button {
        anchors {
            left: parent.left
            top: parent.top
            margins: 10
        }
        text: "get point"
        onClicked: {
            var point = map.positionDisplay.mapPoint;
            console.log("x", point.x, "y", point.y, "wkid", point.spatialReference.wkid)
        }
    }
}