Find graphic added programatically

735
2
03-12-2017 02:38 PM
MarioEstevez
New Contributor III

I'm adding a graphic(polygon) to the map and then I query the layers within the extent of the graphic. In my interface, users can turn layers on and off. What I'm trying to do is re-run the queries when the user turns layers off or additional layers are turned on AFTER a graphic was already added. I'm thinking that if I find the graphic that was added and get its extent, then I can re-query the layers within that extent.

Thanks in advance for your help!!

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Mario,

  When you add the graphic to the map do you add it to the map.graphics? If you add a GraphicsLayer and then add your graphic to that layer then you could just get the graphic from that layer knowing that it is the only graphic in that layer. If you just add it to the maps graphics then you can give the graphic an attribute before you add it then loop through the maps graphics and check for that attribute.

MarioEstevez
New Contributor III

Robert,

Yes, I'm adding the graphic using the map.graphics.add method, sorry for not mentioning that.

Thanks so much for your help. I'll try looping through the map graphics as you suggest.

Thanks!

0 Kudos