当前位置: 首页>>代码示例>>C#>>正文


C# QueryTask类代码示例

本文整理汇总了C#中QueryTask的典型用法代码示例。如果您正苦于以下问题:C# QueryTask类的具体用法?C# QueryTask怎么用?C# QueryTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryTask类属于命名空间,在下文中一共展示了QueryTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:ahthakore,项目名称:arcgis-samples-silverlight,代码行数:26,代码来源:SpatialQuery.xaml.cs

示例2: 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();
        }
开发者ID:Esri,项目名称:arcgis-samples-winphone,代码行数:25,代码来源:InfoWindowDynamic.xaml.cs

示例3: 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;
        }
开发者ID:rlwarford,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:QueryOnly.xaml.cs

示例4: 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();
			}
        }
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:26,代码来源:GetSamples.xaml.cs

示例5: 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);
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:35,代码来源:QueryWithBuffer.xaml.cs

示例6: 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();
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:QueryRelatedTables.xaml.cs

示例7: 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;
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:33,代码来源:Generalize.xaml.cs

示例8: 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");
            }
        }
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:27,代码来源:GetSamples.xaml.cs

示例9: 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);
            }
        }
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:34,代码来源:Statistics.xaml.cs

示例10: 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();
			}
		}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:36,代码来源:QueryRelatedRecords.xaml.cs

示例11: 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");
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:31,代码来源:SpatialQuery.xaml.cs

示例12: RunQuery

        private void RunQuery()
        {
            parcelsGraphicsLayer.Graphics.Clear();

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
            {
                ReturnGeometry = true,
                OutSpatialReference = MyMap.SpatialReference,
                Where = string.Format("OWNER_NAME LIKE '%{0}%'", SearchTextBox.Text),
                OrderByFields = new List<OrderByField>() { new OrderByField("OWNER_NAME", SortOrder.Ascending) }
            };

            query.OutFields.Add("OWNER_NAME,PARCEL_ID,ZONING,DEED_DATE");

            QueryTask queryTask = new QueryTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/MontgomeryQuarters/MapServer/1");
            queryTask.ExecuteCompleted += (s, a) =>
            {
                foreach (Graphic g in a.FeatureSet.Features)
                {
                    parcelsGraphicsLayer.Graphics.Add(g);
                    FeatureListBox.Items.Add(g);
                }

                (ApplicationBar.Buttons[0] as IApplicationBarIconButton).IsEnabled = true;
                FeatureChoicesPage.Visibility = Visibility.Visible;
            };
            FeatureListBox.Items.Clear();
            queryTask.ExecuteAsync(query);
        }
开发者ID:Esri,项目名称:arcgis-samples-winphone,代码行数:29,代码来源:OrderByFieldQuery.xaml.cs

示例13: 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);
            }
        }
开发者ID:rlwarford,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:AttributeQuery.xaml.cs

示例14: 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;
            }
        }
开发者ID:jorik041,项目名称:arcgis-samples-winstore,代码行数:28,代码来源:QueryRelatedRecords.xaml.cs

示例15: 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);
            }
        }
开发者ID:jorik041,项目名称:arcgis-samples-winstore,代码行数:35,代码来源:QueryWithBuffer.xaml.cs


注:本文中的QueryTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。