Can I search Map Graphics

617
2
09-02-2010 06:36 AM
BrandonSchaeffer
New Contributor
Is it possisble to perform a spatial search on temporary map graphics?  For example, I have an add-in that add a bunch of temporary graphics to the map.  Can I take a geometry (such as the new circle in version 1500) that the user has created and use it to do a spatial query for all of the map graphics that fall inside it?  If not with the Graphics can it be done with the Notes that are on the map.  since this can be done with a FeatureLayer or Table it seems like it would be easy to do for the graphics or notes on the map, but I can't find anything in the API.  Could my graphics be programmatically be added to a Table and then I could do the search on the table?

Sorry to put so many questions in one post.  Thanks for any help.

Brandon
0 Kudos
2 Replies
EdanCain
New Contributor II
Hi,
using the SDK all the graphics you add to the mapdisplay you can get back by iterating through the graphics collection. Same goes for Notes, look to the MapDisplay::Map::ChildItems.

Each has a geometry field that you can cast to the relevant geometryType (myGraphic.Geometry.GeometryType;)

You could create a table easily from there and use the relevant pieces to populate it.

If you want to get the graphic that a user clicked on within the map, set up this event handler
_mapDisplay.GraphicClicked += new EventHandler<GraphicMouseEventArgs>       (_mapDisplay_GraphicClicked);

    void _mapDisplay_GraphicClicked(object sender, GraphicMouseEventArgs e)
    {
      Graphic g = e.Graphics[0];
    }

Hope that helps,
Edan
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Brandon,

Just as another option - you could consider using a Geometry Service for the intersect. If you have ArcGIS Server in house you could publish your own Geometry service, otherwise you could use one of the hosted services e.g. http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer.

There's an Intersect operation on the Geometry Server which would give you the functionality you need (see http://sampleserver3.arcgisonline.com/ArcGIS/SDK/REST/index.html?intersect.html for more information).

Plus there's a convenient SOAPConverter object in the Explorer API for convert Explorer geometries to SOAP geometries and vice versa.

Regards

Mike
0 Kudos