I have a very simple task for a QML app, but it's proving to be harder than I expected. I would like to display a set of markers, and then as a function of user input redraw a different set of markers. There are several examples I found for building geometries, but none of tearing them down, nor moving them.
What is the simplest way to accomplish this?
Solved! Go to Solution.
Thanks! As an addition to your suggestions, I also found that I could just nuke the entire set of points by `
graphicsOverlay.graphics.clear()
This lets me sidestep the problem of building the scaffold to tracking individual points separately.
Could I humbly suggest expanding the list of examples to include simple manipulation of points? I think what made it confusing is that move and remove markers can only happen in JS code, whereas the simple creation of the point happens quite naturally in QML.C.f. https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInf....
To add a new graphic marker on the map, you can follow this sample - https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInf...
The graphic is the visual object, which contains geometry (where to display) and a symbol (how to display it).
After you have created a graphic, you can indefinitely assign new Point objects to the Graphic, and it will update (move) location:
e.g.
const pt = ArcGISRuntimeEnvironment.createObject("Point", {x: 1.2, y: 3.4});
graphic.geometry = pt;
To remove/tear down the graphic, simply remove the graphic from the graphics overlay:
e.g.
graphicsOverlay.graphics.removeOne(graphic);
https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-graphiclistmodel.html
Thanks! As an addition to your suggestions, I also found that I could just nuke the entire set of points by `
graphicsOverlay.graphics.clear()
This lets me sidestep the problem of building the scaffold to tracking individual points separately.
Could I humbly suggest expanding the list of examples to include simple manipulation of points? I think what made it confusing is that move and remove markers can only happen in JS code, whereas the simple creation of the point happens quite naturally in QML.C.f. https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInf....