dear
i'm developing gis xamarin app
how i can make spatial query
i select 1 region from first layer
and i want to select all cities within selected resgion
i pass geometry of selected feature to the query but it not work
any help plz
Hi Mohammed,
Using GeometryEngine.Intersection() method, I was able to select the cities with a state. Below is the code, since it has the XAML part for the Graphics Overlay, I have attached the project, the project is in WPF..
// City Layer
FeatureLayer cityLayer = new FeatureLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"));
// State Layer
FeatureLayer stateLayer = new FeatureLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"));
MyMap.OperationalLayers.Add(cityLayer);
MyMap.OperationalLayers.Add(stateLayer);
// State Query
QueryParameters stateQueryParameters = new QueryParameters();
// only select one polygon from State layer
stateQueryParameters.WhereClause = "state_name = 'California'";
// Query the State feature table
FeatureQueryResult stateQueryResult = await stateLayer.FeatureTable.QueryFeaturesAsync(stateQueryParameters);
var stateResult = stateQueryResult.ToList();
// City Query
QueryParameters cityQueryParameter = new QueryParameters();
cityQueryParameter.WhereClause = "1=1";
// Query the City feature table
FeatureQueryResult cityQueryResult = await cityLayer.FeatureTable.QueryFeaturesAsync(cityQueryParameter);
var cities = cityQueryResult.Select(feature => feature.Geometry);
var citiesWithinState = cities
.Select(city => GeometryEngine.Intersection(city, stateResult[0].Geometry))
.Select(city => new Graphic(city, _markerSymbol));
foreach (Graphic g in citiesWithinState)
{
_pointFeatureOverlay.Graphics.Add(g);
}
}
Hope that helps.
Nagma
Thank you very much Nagma
its worked with me
but i have problem
by rendering graphics the result is 100% true
but when i make add watch and i tracing the (citiesWithinState) parameter it not have just features withen first result geometry
it have all cities in the gdb (because i want to binding cities name also how i can get it)