Select to view content in your preferred language

Disable panning

3537
1
Jump to solution
07-06-2015 08:25 AM
PremRadhakrishnan
Regular Contributor

Hello,

I am trying to use the MousePress, MousePositionChanged and MouseRelease signals to capture a selection rectangle, the issue that I have is I want to disable panning if a flag is set and then enabled it so that during the action the map does not pan.

Is there anyway to do this?

Thanks,

Prem

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

You can set up a handler for the mousePositionChanged signal and accept the mouse events depending on if your panning flag is enabled or not. Something like the following should get you started.

Thanks,

Luke

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import ArcGIS.Extras 1.0
import ArcGIS.Runtime 10.26


ApplicationWindow {
    id: rootRectangle
    width: 500
    height: 500


    property bool isPannable: true


    Envelope {
        id: extentEnvelope
        xMin: -122.511
        yMin: 37.7474
        xMax: -122.3887
        yMax: 37.8125
        spatialReference: SpatialReference {
            wkid: 4326
        }
    }


    Map {
        id: mainMap
        anchors.fill: parent
        extent: extentEnvelope
        focus: true


        ArcGISLocalTiledLayer {
            id: baseArcGISLocalTiledLayer
            path: "~/ArcGIS/Runtime/Data/tpks/SanFrancisco.tpk"
        }


        onMouseClicked: {
            console.log("clicked", mouse.mapX)
        }


        onMousePositionChanged:  {
            if (!isPannable) {
                mouse.accepted = true;
            } else {
                mouse.accepted = false;
            }
        }
    }


    Button {
        text: "disable panning"
        onClicked: {
            if (isPannable)
                isPannable = false;
            else
                isPannable = true;
        }
    }
}
















View solution in original post

0 Kudos
1 Reply
LucasDanzinger
Esri Frequent Contributor

You can set up a handler for the mousePositionChanged signal and accept the mouse events depending on if your panning flag is enabled or not. Something like the following should get you started.

Thanks,

Luke

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import ArcGIS.Extras 1.0
import ArcGIS.Runtime 10.26


ApplicationWindow {
    id: rootRectangle
    width: 500
    height: 500


    property bool isPannable: true


    Envelope {
        id: extentEnvelope
        xMin: -122.511
        yMin: 37.7474
        xMax: -122.3887
        yMax: 37.8125
        spatialReference: SpatialReference {
            wkid: 4326
        }
    }


    Map {
        id: mainMap
        anchors.fill: parent
        extent: extentEnvelope
        focus: true


        ArcGISLocalTiledLayer {
            id: baseArcGISLocalTiledLayer
            path: "~/ArcGIS/Runtime/Data/tpks/SanFrancisco.tpk"
        }


        onMouseClicked: {
            console.log("clicked", mouse.mapX)
        }


        onMousePositionChanged:  {
            if (!isPannable) {
                mouse.accepted = true;
            } else {
                mouse.accepted = false;
            }
        }
    }


    Button {
        text: "disable panning"
        onClicked: {
            if (isPannable)
                isPannable = false;
            else
                isPannable = true;
        }
    }
}
















0 Kudos