Select to view content in your preferred language

How to draw rectangle and zoom to it in QT ARC GIS

1160
4
01-07-2019 04:51 AM
Girishchandra_Yendargaye
Occasional Contributor

I want to implement zoom to area feature by drawing rectangle in QT local offline app.

Could you please suggest right way to do it....

which methods to call ...

Tags (1)
0 Kudos
4 Replies
LucasDanzinger
Esri Frequent Contributor

Essentially you need to draw a rectangle on the screen and convert the corners from screen coordinates to map coordinates. Once you do that, you can get an Envelope representing the extent, and then create a ViewpointExtent from the envelope, and setViewpoint on the MapView.

We have an example similar to what you are looking for, where the sample draws a rectangle and converts it to an Envelope so that this area can be taken offline. You can based your example off this only instead of exporting tiles, you'd zoom to the Envelope

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Layers/ExportTiles at master · Esri/arcgis-r... 

0 Kudos
Girishchandra_Yendargaye
Occasional Contributor

I am trying to use CPP + QML...I am handling mouse click event but panning is not allowing me to draw Reactangle How disable it.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

There are some examples of this here - arcgis-runtime-qt-projects-100/OverrideMapSignals at master · ldanzinger/arcgis-runtime-qt-projects-... 

For example, you could do:

connect(m_mapView, &MapQuickView::mousePressed, [](QMouseEvent& event)
{
    // accept the event - this will prevent the default panning from happening
    event.accept();
});
Girishchandra_Yendargaye
Occasional Contributor

Thanks it's working what to do in case on second button click I want to release this connect and connect with new one .

0 Kudos