I have a query that returns a list of records that are related to various States (polygons) and I want to link those records to the individual States. I am having problems to extract the individual States from the State boundary GraphicsLayer. here a set of the codes:
private Graphic getStateBoundaryGraphic(string ST) { GraphicsLayer usaGraphics = MyMap.Layers["StatesUSA"] as GraphicsLayer; Graphic state = new Graphic(); foreach (Graphic g in usaGraphics) { if (g.Attributes["STATE"] == ST) state = g; } return state; }
[ERROR MESSAGE:] "foreach (Graphic g in usaGraphics)" Object reference is not set which is null which is NOT true.
The key is that (1) the Shape column must be included (or existing) in the Map Service Layer and (2) the query's parameter xxx.ReturnedGeometry must be set to true. Then you can do whatever you want to do (clone, capture attributes, geometry, etc.) with the returned graphic. Cheers
The key is that (1) the Shape column must be included (or existing) in the Map Service Layer and (2) the query's parameter xxx.ReturnedGeometry must be set to true. Then you can do whatever you want to do (clone, capture attributes, geometry, etc.) with the returned graphic. Cheers