Is it possible to override default map features?

575
1
Jump to solution
08-22-2017 05:35 AM
NicholasLiccini
New Contributor II

Is there any way to use C++ or QML to override the default behaviors of the MapView such as double click to zoom in?

My idea was to extend the MapQuickView class and give it custom features

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

One option would be to subclass MapView. In the API, we have MapView subclassed as MapQuickView (for Qt Quick) and MapGraphicsView (for Qt Widgets), so you could subclass MapView on your own and add whatever default behaviors you want to your own CustomMapQuickView.

A simpler but less elegant option would be to add a MouseArea over your MapView in QML. This automatically accepts all mouse/wheel events that go through, so you would need to listen to the various signal handlers and then have those call functions that do whatever you want.

MapView {
    anchors.fill: parent
    objectName: "mapView"

    MouseArea {
        anchors.fill: parent
        onDoubleClicked: {
            console.log("double click");
            customCppFunctionToHandleDoubleClicks();
        }
        onClicked: {
            console.log("single click");
            customCppFunctionToHandleSingleClicks();
        }
    }
}

View solution in original post

1 Reply
LucasDanzinger
Esri Frequent Contributor

One option would be to subclass MapView. In the API, we have MapView subclassed as MapQuickView (for Qt Quick) and MapGraphicsView (for Qt Widgets), so you could subclass MapView on your own and add whatever default behaviors you want to your own CustomMapQuickView.

A simpler but less elegant option would be to add a MouseArea over your MapView in QML. This automatically accepts all mouse/wheel events that go through, so you would need to listen to the various signal handlers and then have those call functions that do whatever you want.

MapView {
    anchors.fill: parent
    objectName: "mapView"

    MouseArea {
        anchors.fill: parent
        onDoubleClicked: {
            console.log("double click");
            customCppFunctionToHandleDoubleClicks();
        }
        onClicked: {
            console.log("single click");
            customCppFunctionToHandleSingleClicks();
        }
    }
}