Removing selected graphics from map

2412
4
02-14-2013 07:13 AM
JonathanKressin
New Contributor III
Hello,

I am adding the ability to delete created graphics in my application.  I have it working pretty well with an extent being drawn and features that are contained/intersect the extent are removed. (using extent.contains and extent.intersects)

However, when working with point features, especially text and large symbols, the user has to select the exact point where the symbol was inserted using this method.  Is there an alternate way to do this so that a user can select any part of the symbol and remove the graphic?

Thanks!
Jonathan
0 Kudos
4 Replies
StephenLead
Regular Contributor III
when working with point features, especially text and large symbols, the user has to select the exact point


Hi Jonathan,

You can get around this by buffering the point clicked by the user, and using the buffer to select your graphics. There's a sample here which shows how to get started.

Steve
0 Kudos
JonathanKressin
New Contributor III
Hi Jonathan,

You can get around this by buffering the point clicked by the user, and using the buffer to select your graphics. There's a sample here which shows how to get started.

Steve


Steve,

Thanks for your response.  I didn't think you could use the QueryTask against a graphics layer, as it isn't an operational layer you can initialize the query with.  If I understand you correctly, you are suggesting I basically create a bubble (the buffer) around a point clicked and then query for any graphics within that space.  This seems even less precise then allowing the user to draw a box around the object, as then not only do they have to click within a certain distance of the center point of the point, but they will be more likely to select and delete other nearby graphics.

An example of what I want to do is this:  draw a large cross symbol on the map and be able to click on any of the arms of that cross to select it but not select it if I click on the white space between arms.  I have seen this done on other current GIS web applications, so I know it is possible.  I just don't know how to get to the point where I am interacting with what is drawn on the screen versus its point representation in the graphics layer.

Thanks,

Jonathan
0 Kudos
StephenLead
Regular Contributor III
you are suggesting I basically create a bubble (the buffer) around a point clicked and then query for any graphics within that space.


This is necessary when selecting a point, since it's virtually impossible for you to click exactly on the point's location. Instead, you want to select any point within a certain distance of the mouse coordinates. This distance can be very small, eg 3 pixels. Note that even in ArcMap, that's what happens when you use the Select tool.

This seems even less precise then allowing the user to draw a box around the object, as then not only do they have to click within a certain distance of the center point of the point, but they will be more likely to select and delete other nearby graphics.


You could use logic such as:

- if only one point is returned, delete it
- if multiple features are returned, highlight them and let the user toggle through them to decide which one(s) to delete

An example of what I want to do is this:  draw a large cross symbol on the map and be able to click on any of the arms of that cross to select it but not select it if I click on the white space between arms.  I have seen this done on other current GIS web applications, so I know it is possible.  I just don't know how to get to the point where I am interacting with what is drawn on the screen versus its point representation in the graphics layer.


You'd need to write this yourself as there's nothing out-of-the-box which will do this. The basic principle will be the same though - rather than searching for points within the circular buffer you'd be searching within the cross-shaped graphic.

Good luck,
Steve
0 Kudos
JonathanKressin
New Contributor III
Steve,

Reading your posts again, perhaps I am just misunderstanding a key point in this.  When I create a buffer against a graphics layer containing point features, does it query against the single map point, or does it actually run the query against the pixels of the actual graphic in that layer?  I was assuming the former, but if it is actually querying all the pixels that make up a single graphic, I can see how this could work.

Thanks again,
Jonathan
0 Kudos