AppStudio 5.2 - How to create a selection rectangle in MapView?

01-13-2022 01:05 PM
New Contributor II

Hello community,

I'm using AppStudio 5.2 and the 5.2 Map Viewer template connected to a secured ArcGIS Online Web Map. I have written some code that listens for mouse activity and under certain conditions (my own) a map selection box is drawn while the mouse button is pressed.
The MapView onMousePressed, onMousePositionChanged, and onMouseReleased events are used and all seems fine while working on a Windows laptop. When running the app on an iPad only the onMousePressed fires. I was hoping that dragging a finger would fire onMousePositionChanged and lifting the finger would fire onMouseReleased. Optimistic, I know.

In short, what is the best way to interactively create a rectangular selection box in iOS?

I'm developing in Windows and targeting iOS.
Anyone have any ideas?


0 Kudos
2 Replies
Esri Contributor

Hi @BurnsideAdmin ,

You should be able to use the MouseArea QML component and the onMouseXChanged, onMouseYChanged, onPressed, and onReleased signals should trigger using touch screens. I was able to test using my iPhone and console logging mouseX and mouseY to see the coordinates update.

Another option we use in some of our template apps is to drop a point on the map using a mouse clicked event, then click to add another point to draw a line. You can find a good example of this here that demonstrates how to draw points, lines, and polygons. 

Hope this helps. 

0 Kudos
New Contributor II

Thanks, Trevor.

I was able to use your MouseArea idea. As an API enhancement, I suggest modifying the QML MapView (GeoView) mouse events to allow for screen gestures.


0 Kudos