Selection of a graphic by an unique identifier

255
2
Jump to solution
08-24-2017 03:07 AM
Bhargav_KumarK
New Contributor

In 10.2.6 of Arc GIS Runtime SDK for Qt, we used to create a graphic and on adding this to a Graphic Layer we get 'id'. With this 'id' we can access that graphic for modification or updation on GraphicLayer. How to achieve this functionality in ArcGIS Runtime SDK for Qt 100.1 with out using identifyGraphicsOverlay method (this function is used during mouse click)? One way to acheive this is like, get all graphics on GraphicsOverlay and iterate to get required graphic by searching with required atttribute. But this may take time for traversal as this is regular operation. For example we may want to update a graphic on everytime we receive gps location.  

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi - you are correct there is no "ID" obtained when adding a Graphic in Qt 100.1. Which version of the API are you using?

For C++, I think you could probably store this as a QMap<QString, Graphic*>> where the key is a label/ID that you assign to help keep track of the graphic. You would also need to take care to keep your map in step with the `GraphicListModel` - e.g. remove the graphic from both structures at the same time and so on. Note that the model does not assume ownership of the `Graphic` when it is added.

In theory, you could use the index at which you added the `Graphic` into the `GraphicListModel` but this is not guaranteed to be stable since the model also supports inserts and so on.

I hope that helps,

Luke

View solution in original post

0 Kudos
2 Replies
LukeSmallwood
Esri Contributor

Hi - you are correct there is no "ID" obtained when adding a Graphic in Qt 100.1. Which version of the API are you using?

For C++, I think you could probably store this as a QMap<QString, Graphic*>> where the key is a label/ID that you assign to help keep track of the graphic. You would also need to take care to keep your map in step with the `GraphicListModel` - e.g. remove the graphic from both structures at the same time and so on. Note that the model does not assume ownership of the `Graphic` when it is added.

In theory, you could use the index at which you added the `Graphic` into the `GraphicListModel` but this is not guaranteed to be stable since the model also supports inserts and so on.

I hope that helps,

Luke

View solution in original post

0 Kudos
Bhargav_KumarK
New Contributor

Thanks Luke. I was using your suggestion of QMap<QString, Graphic *>>.

0 Kudos