本文整理汇总了C#中QueryTask.ExecuteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# QueryTask.ExecuteAsync方法的具体用法?C# QueryTask.ExecuteAsync怎么用?C# QueryTask.ExecuteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryTask
的用法示例。
在下文中一共展示了QueryTask.ExecuteAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunQuery
private async Task RunQuery(IGeometry geometry)
{
var l = MyMap.Layers["GraphicsWellsLayer"] as GraphicsLayer;
l.Graphics.Clear();
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
ESRI.ArcGIS.Runtime.Tasks.Query query = new ESRI.ArcGIS.Runtime.Tasks.Query()
{
Geometry = geometry,
ReturnGeometry = true,
OutSpatialReference = MyMap.SpatialReference,
OutFields = OutFields.All
};
try
{
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
ResultsGrid.ItemsSource = result.FeatureSet.Features;
l.Graphics.AddRange(from g in result.FeatureSet.Features select g);
}
}
catch (Exception ex)
{
return;
}
}
示例2: mapView1_Tapped_1
private async void mapView1_Tapped_1(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
{
var mp = e.Location;
Graphic g = new Graphic() { Geometry = mp };
var graphicsLayer = mapView1.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.Graphics.Add(g);
var bufferResult = GeometryEngine.Buffer(mp, 100);
var bufferLayer = mapView1.Map.Layers["BufferLayer"] as GraphicsLayer;
bufferLayer.Graphics.Add(new Graphic() { Geometry = bufferResult });
var queryTask = new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
var query = new Query("1=1")
{
ReturnGeometry = true,
OutSpatialReference = mapView1.SpatialReference,
Geometry = bufferResult
};
query.OutFields.Add("OWNERNME1");
try
{
var queryResult = await queryTask.ExecuteAsync(query);
if (queryResult != null && queryResult.FeatureSet != null)
{
var resultLayer = mapView1.Map.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
resultLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例3: mapView_MapViewTapped
// Select a set of wells near the click point
private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_wellsLayer.Graphics.Clear();
wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
Query query = new Query("1=1")
{
Geometry = Expand(mapView.Extent, e.Location, 0.01),
ReturnGeometry = true,
OutSpatialReference = mapView.SpatialReference,
OutFields = OutFields.All
};
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
_wellsLayer.Graphics.AddRange(result.FeatureSet.Features);
wellsGrid.ItemsSource = result.FeatureSet.Features;
resultsPanel.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例4: RunQuery
private async void RunQuery()
{
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"));
Query query = new Query("1=1")
{
GroupByFieldsForStatistics = new List<string> { "sub_region" },
OutStatistics = new List<OutStatistic> {
new OutStatistic(){
OnStatisticField = "pop2000",
OutStatisticFieldName = "subregionpopulation",
StatisticType = StatisticType.Sum
},
new OutStatistic(){
OnStatisticField = "sub_region",
OutStatisticFieldName = "numberofstates",
StatisticType = StatisticType.Count
}
}
};
try
{
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
ResultGrid.ItemsSource = result.FeatureSet.Features;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例5: MyMapView_MapViewTapped
// Select a set of wells near the click point
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_wellsOverlay.Graphics.Clear();
wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
// Get current viewpoints extent from the MapView
var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
Query query = new Query("1=1")
{
Geometry = Expand(viewpointExtent, e.Location, 0.01),
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
OutFields = OutFields.All
};
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
_wellsOverlay.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
wellsGrid.ItemsSource = result.FeatureSet.Features;
resultsPanel.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例6: doQuery
private async Task doQuery()
{
// Clear previous results and show busy indicator
ResultsItemsControl.ItemsSource = null;
ProgressBar.Visibility = Visibility.Visible;
// Create task to query for states
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));
// Specify query parameters. Query for the inptu text and include all fields in the results
Query query = new Query(StateNameTextBox.Text);
query.OutFields.Add("*");
try
{
// Do the query and update the results
var result = await queryTask.ExecuteAsync(query);
ResultsItemsControl.ItemsSource = result.FeatureSet.Features;
}
catch (TaskCanceledException taskCanceledEx)
{
System.Diagnostics.Debug.WriteLine(taskCanceledEx.Message);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
// Hide busy indicator
ProgressBar.Visibility = Visibility.Collapsed;
}
示例7: QueryImageTiles
// Query the image service for sample tiles
private async Task QueryImageTiles()
{
try
{
var envelope = await MyMapView.Editor.RequestShapeAsync(DrawShape.Envelope) as Envelope;
QueryTask queryTask = new QueryTask(
new Uri("http://servicesbeta.esri.com/ArcGIS/rest/services/Portland/PortlandAerial/ImageServer/query"));
Query query = new Query(envelope)
{
OutFields = new OutFields(new string[] { "Name", "LowPS" }),
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
Where = "Category = 1"
};
var result = await queryTask.ExecuteAsync(query);
_graphicsOverlay.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Sample Error");
}
}
示例8: MyMap_Tapped_1
private async void MyMap_Tapped_1(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
Graphic g = new Graphic() { Geometry = mp };
var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.Graphics.Add(g);
var bufferResult = GeometryEngine.Buffer(mp, 100);
var bufferLayer = MyMap.Layers["BufferLayer"] as GraphicsLayer;
bufferLayer.Graphics.Add(new Graphic() { Geometry = bufferResult });
var queryTask = new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
var query = new ESRI.ArcGIS.Runtime.Tasks.Query()
{
ReturnGeometry = true,
OutSpatialReference = MyMap.SpatialReference,
Geometry = bufferResult
};
query.OutFields.Add("OWNERNME1");
try
{
var queryResult = await queryTask.ExecuteAsync(query);
if (queryResult != null && queryResult.FeatureSet != null)
{
var resultLayer = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
resultLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例9: mapView1_Loaded
async void mapView1_Loaded(object sender, RoutedEventArgs e)
{
if (originalGraphicsLayer != null && originalGraphicsLayer.Graphics.Count == 0)
{
QueryTask queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/1"));
Query query = new Query("NAME = 'Mississippi'");
query.ReturnGeometry = true;
query.OutSpatialReference = mapView1.SpatialReference;
var results = await queryTask.ExecuteAsync(query, CancellationToken.None);
foreach (Graphic g in results.FeatureSet.Features)
{
g.Symbol = defaultLineSymbol;
g.Geometry.SpatialReference = mapView1.SpatialReference;
originalGraphicsLayer.Graphics.Add(g);
foreach (var pc in (g.Geometry as Polyline).Paths)
{
foreach (var point in pc)
{
var vertice = new Graphic()
{
Symbol = defaultMarkerSymbol,
Geometry = new MapPoint(point.X, point.Y)
};
originalGraphicsLayer.Graphics.Add(vertice);
}
}
}
GeneralizeButton.IsEnabled = true;
}
}
示例10: QueryImageTiles
// Query the image service for sample tiles
private async Task QueryImageTiles()
{
try
{
var envelope = await MyMapView.Editor.RequestShapeAsync(DrawShape.Envelope) as Envelope;
var imageLayer = MyMapView.Map.Layers["ImageLayer"] as ArcGISImageServiceLayer;
QueryTask queryTask = new QueryTask(new Uri(imageLayer.ServiceUri));
Query query = new Query(envelope)
{
OutFields = new OutFields(new string[] { "Name", "LowPS" }),
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
Where = "Category = 1"
};
var result = await queryTask.ExecuteAsync(query);
_graphicsOverlay.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
}
catch (Exception ex)
{
var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例11: MyDrawSurface_DrawComplete
private void MyDrawSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
ResultsDisplay.Visibility = Visibility.Collapsed;
MyDrawObject.IsEnabled = false;
selectionGraphicslayer.ClearGraphics();
QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
// Bind data grid to query results
Binding resultFeaturesBinding = new Binding("LastResult.Features");
resultFeaturesBinding.Source = queryTask;
QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
// Specify fields to return from query
query.OutFields.AddRange(new string[] { "STATE_NAME", "SUB_REGION", "STATE_FIPS", "STATE_ABBR", "POP2000", "POP2007" });
query.Geometry = args.Geometry;
// Return geometry with result features
query.ReturnGeometry = true;
query.OutSpatialReference = MyMap.SpatialReference;
queryTask.ExecuteAsync(query);
}
示例12: initializeComboBox
private async Task initializeComboBox()
{
if (QueryListPicker.ItemsSource != null) // already initialized
return;
// Construct the query to return all features (where clause of "1=1") and only the state name
Query query = new Query("1=1") { ReturnGeometry = false };
query.OutFields.Add("STATE_NAME");
QueryTask queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));
try
{
// Do the query
var result = await queryTask.ExecuteAsync(query);
// Make sure results were received
if (result != null && result.FeatureSet != null && result.FeatureSet.Features != null)
{
// Add the states to the list picker, ordered by state name
QueryListPicker.ItemsSource = result.FeatureSet.Features.OrderBy(
x => x.Attributes["STATE_NAME"]);
// Enable the list picker and hide the busy indicator
QueryListPicker.IsEnabled = true;
progress.Visibility = Visibility.Collapsed;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例13: mapView_MapViewTapped
// buffer the click point, query the map service with the buffer geometry as the filter and add graphics to the map
private async void mapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
{
try
{
graphicsLayer.Graphics.Add(new Graphic(e.Location));
var bufferResult = GeometryEngine.Buffer(e.Location, 100);
bufferLayer.Graphics.Add(new Graphic(bufferResult));
var queryTask = new QueryTask(
new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
var query = new Query("1=1")
{
ReturnGeometry = true,
OutSpatialReference = mapView.SpatialReference,
Geometry = bufferResult
};
query.OutFields.Add("OWNERNME1");
var queryResult = await queryTask.ExecuteAsync(query);
if (queryResult != null && queryResult.FeatureSet != null)
{
parcelLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Spatial Query Sample");
}
}
示例14: dispatcherTimer_Tick
void dispatcherTimer_Tick(object sender, EventArgs e)
{
_infoWindow.IsOpen = false;
QueryTask queryTask =
new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4");
Query query = new Query()
{
Geometry = _tapPoint,
OutSpatialReference = MyMap.SpatialReference
};
query.OutFields.Add("NAME");
queryTask.ExecuteCompleted += (s, evt) =>
{
if (evt.FeatureSet.Features.Count > 0)
{
_infoWindow.Anchor = _tapPoint;
(_infoWindow.Content as TextBlock).Text = evt.FeatureSet.Features[0].Attributes["NAME"] as string;
_infoWindow.IsOpen = true;
}
};
queryTask.ExecuteAsync(query);
_dispatcherTimer.Stop();
}
示例15: LoadParcelsAsync
// Load parcels from map service
private async Task LoadParcelsAsync()
{
var queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/AssessorsParcelCharacteristics/MapServer/1"));
var query = new Query(mapView.Extent) { ReturnGeometry = true, OutSpatialReference = mapView.SpatialReference, OutFields = new OutFields(new List<string> { "Shape" }) };
var result = await queryTask.ExecuteAsync(query);
parcelLayer.Graphics.Clear();
parcelLayer.Graphics.AddRange(result.FeatureSet.Features);
}