Remove previously added graphics from map

999
1
09-19-2016 10:32 AM
jayshukla
New Contributor III

Hi All, As part of my application, I add graphics to a map for a list of features that meet criteria (in cyan). User can select a single record from a list. Application logic adds another graphic for selected record (callout in red). If user click on another record, I want to remove the previously added graphics (red callout) while still maintaining my graphics for original list (in cyan). Is there way I can get handle of graphics that was last added, graphics below shows this scenario. Appreciate any feedback. Thanks Jay      

0 Kudos
1 Reply
Drew
by
Occasional Contributor III

It might be best to keep track of that graphic when you add it. Then just manage it in code.

You can move it using the "setGeometry(..) function or hide() and show() as needed.

Graphic | API Reference | ArcGIS API for JavaScript 3.17