Hi was wondering if any one can help me with this?
The example linked here - Code Example - IdentifyTask
Shows how to perform a hit test with the mouse on features in layers of a MapView
Can this also be done without having to reference a serviceURI using Esri.ArcGISRuntime.Tasks.Query.IdentifyTask(...) as all my data is from local storage shape files and not from a server.
I see the Layer.HitTestAsync() but this seems limited in functionality.
Loading shape files as follows..
Esri.ArcGISRuntime.Data.ShapefileTable mySFT = await Esri.ArcGISRuntime.Data.ShapefileTable.OpenAsync("C:\\blabla.shp");
var myQueryFilter = new Esri.ArcGISRuntime.Data.QueryFilter();
myQueryFilter.WhereClause = "1=1";
var Mines = mySFT.QueryAsync(myQueryFilter);
var myLayer = new Esri.ArcGISRuntime.Layers.FeatureLayer(mySFT);
myLayer.ID = "layer_id";
MyMapView.Map.Layers.Add(myLayer);
Thanks
Solved! Go to Solution.
You most likely need to create the item template for the datagrid where you define the look and feel for each row. You can access the attributes from xaml using 'Attributes[key]' definition when the DataContext is the feature. Something like this {Binding Attributes[OBJECTID]}.
Another thing that you can do is to filter the attributes in code and then provide the filtered list as a ItemsSource.
Hey,
You can do SpatialQuery against your ShapefileTable to get features based on geometry. See Search for features—ArcGIS Runtime SDK for .NET | ArcGIS for Developers for more information (Query offline content). In the doc query is done against GeodatabaseFeatureTable but that should work the same way against Shapefile.
Can you clarify what you mean with HitTestAsync being limited with it's functionality?
With .NET SDK, please use ArcGIS Runtime SDK for .NET place.
IdentifyTask is a class that helps you execute the "Identify" operation on ArcGIS server. This is useful when consuming map services where the features aren't stored locally.
HitTestAsync is used for "hitting" graphics and features in GraphicsLayer and FeatureLayer that are rendered and visible in the map view and therefore already available locally (as opposed to on the server). These are pixel-based evaluations, meaning it's easier to hit a point with a very large marker symbol than a small one. The spatial queries using QueryAsync(SpatialQueryFilter) doesn't have this benefit, since it's performed at the geometry level.
Depending on the data and the scenario you're trying to solve, decides with operation you should be using.
Typically if you want you user to "click" on a feature rendered by FeatureLayer or GraphicsLayer, HitTestAsync is what you will use, passing in the screen location the user clicked.
how i can specified the output fields from result ?
like this
var query = new Esri.ArcGISRuntime.Data.QueryFilter();
query.WhereClause = "'";
// query.OutFields.Add("field1"); this one not available in query filter
if (table.SupportsQuery)
{
// Query the table and await the result
var result = await table.QueryAsync(query);
Outfields only applies to online services as a way to reduce response sizes, by filtering out fields you may not need. This isn't an issue for local data, and all fields are always returned.
thanks Morten for reply , and how i can specify which fields to show in data grid or result come back from HitTestAsyn ?
Please have a look to FeatureLayerHitTesting sample in https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/master/src/Desktop/ArcGISRuntimeSamplesDe...
It is using HitTesting to fetch the feature information and then showing it in the UI.
You need to define what fields are used in your data grid based on the grids mechanism. Attributes are returned in Dictionary that you can easily access.
i know how to get data from HitTesting and here is sample of my code ,
var feature = await layer.FeatureTable.QueryAsync(featureID);
resultsGrid1.ItemsSource = feature.Attributes;
here its return all fields pairs (key and value) so my question how to choose spacific fields
You most likely need to create the item template for the datagrid where you define the look and feel for each row. You can access the attributes from xaml using 'Attributes[key]' definition when the DataContext is the feature. Something like this {Binding Attributes[OBJECTID]}.
Another thing that you can do is to filter the attributes in code and then provide the filtered list as a ItemsSource.
thanks antti for help
i use second solution