You will learn: how to build an app to create geometries and graphics from coordinates and add them to a map.
Applications can display point, line, and polygon graphics on a map. Graphics are composed of a geometry, a symbol, a set of attributes, and they can display a pop-up when clicked. Graphics are commonly created by interacting with the map or by creating small sets of data manually that you want to display on a map. Graphics can be directly initialized with the Graphic QML type and displayed on a map with the GraphicsOverlay class.
In this tutorial, you will build a simple app that draws point, polyline, and polygons graphic near Malibu beach, California.
If you completed the Create a starter app tutorial, start ArcGIS AppStudio and then open your starter app project. Otherwise, complete the tutorial now and open the project.
Steps
Run ArcGIS AppStudio. Click your Starter app project in the App Gallery, and then click {;} Edit. This will open your project in Qt Creator.
Add a graphics overlay
In the Qt Creator Projects window, double-click MyApp.qml to open it in the editor.
In the code editor, scroll down to the MapView declaration. Before the Map declaration, add a GraphicsOverlay property.
GraphicsOverlay is a container for temporary graphics to display on your map view. The Graphics drawn in graphics overlays are created at runtime and are not persisted when your application closes. To create data that is persisted, visit the Import data and Create a new dataset tutorials.
A MapView supports a collection of graphics overlays, using the graphicsOverlays list model, similar to how operational layers are managed.
Add these components to the MapView, at the same level as the SimpleMarkerSymbol previously added.
Note that the code pattern here is similar to the point symbol, graphic, and geometry builder you coded in the prior steps, with the exception of setting the polyline geometry dynamically at runtime using PolylineBuilder.
Polyline graphics support a number of symbol types such as SimpleLineSymbol and TextSymbol. They are called polylines because they support multiple, disjointed line segments as one geometry.
Add code to the Component.onCompleted handler to use the PolylineBuilder QML type to dynamically create the line geometry and append it to the graphics overlay.
Add code to the Component.onCompleted hander to use the PolygonBuilder QML type to dynamically create the polygon geometry and append it to the graphics overlay.