Delete Graphic in a Graphic Layer

4497
3
01-27-2011 12:31 PM
JaclynGorman
New Contributor
I've looked at other posts but I can't figure out what I am doing wrong.  I am creating 2 graphics with my code.  A point and a buffer.  Basically the user will buffer an area and then be able to mark locations inside the buffer area with points (They can choose between 4 points within a drop-down box).  I tried to create a graphic layer so that I can have separate clear buttons for the buffer and points.  I can't get the points to clear.  I tried  onclick= "Graphiclayer.clear()" , but that doesn't work.  Currently, I have onclick="map.getLayer('Graphic Layer ID').clear()."  The second way only removes the last created point, but the user will be adding multiple points.  I am not a programmer/ developer so any help would be appreciated.  Ideally it would be awesome if you could remove one point at a time (similar to this example http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm) but I will settle for just having the buffer and all the points being removed separately.

I am attaching a text file with my code.

Thanks

Jaclyn
0 Kudos
3 Replies
DavidMaltby
New Contributor
you are missing a ; after map.graphics.clear()

change to map.graphics.clear();
0 Kudos
JaclynGorman
New Contributor
Fixed that issue, but unfortunately it didn't solve the clearing issue.  When I go to clear the point graphics it still only clears the last point created and not all the points.
0 Kudos
JaclynGorman
New Contributor
I figured it out.  I added the graphics layer to the global variable list and it works. Thanks

Jaclyn
0 Kudos