Hi to all, i've this case: one feature layer with 1 polygon on map, and a service whith many smaller polygon. I would like to do a spatial query where the geometry of task is the polygon of the feature layer. The result of this maybe the polygons of service layer that are contained in larger polygon of feature layer. This is the code of task .... always task execute failed .... 😞 Thank's to all for help me to solve this error GP
//Specify fields to return from query query.OutFields.AddRange(new string[] { "myoutfield" }); FeatureLayer f = MyMap.Layers["MyFeatureLayer"] as FeatureLayer; query.SpatialRelationship = SpatialRelationship.esriSpatialRelContains;
query.Geometry = f.Geometry; // Return geometry with result features query.ReturnGeometry = true;
Did you verify in debug that f.Geometry is not null? That's supposed to be the spatial filter for your feature layer but, except if you set it explicitely, it's null. If you are sure that there is only one feature in your layer, you could try :