コード例 #1
0
        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);
            }
        }
コード例 #2
0
        private async Task RunQuery()
        {
            QueryTask queryTask =
                new QueryTask(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"));

            ESRI.ArcGIS.Runtime.Tasks.Query query = new ESRI.ArcGIS.Runtime.Tasks.Query()
             {
                 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);
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        private async Task GetAttributes()
        {
            QueryTask queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));

            ESRI.ArcGIS.Runtime.Tasks.Query query = new ESRI.ArcGIS.Runtime.Tasks.Query()
            {
                OutFields = OutFields.All,
                ReturnGeometry = true,
                Text = (string)(QueryComboBox.SelectedItem as Graphic).Attributes["STATE_NAME"],
                OutSpatialReference = MyMap.SpatialReference
            };
            try
            {
                ResultsGrid.ItemsSource = null;
                progress.IsActive = true;
                var result = await queryTask.ExecuteAsync(query);
                var featureSet = result.FeatureSet;
                // If an item has been selected            
                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Clear();

                if (featureSet != null && featureSet.Features.Count > 0)
                {
                    var symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Runtime.Symbology.ISymbol;
                    var g = featureSet.Features[0];
                    graphicsLayer.Graphics.Add(g);
                    var selectedFeatureExtent = g.Geometry.Extent;
                    ESRI.ArcGIS.Runtime.Envelope displayExtent = selectedFeatureExtent.Expand(1.3);
                    MyMap.ZoomTo(displayExtent);
                    ResultsGrid.ItemsSource = g.Attributes;
                }
            }
            catch (Exception ex)
            {

                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                progress.IsActive = false;
            }
        }
コード例 #5
0
        private async Task InitializeComboBox()
        {
            QueryTask queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));


            ESRI.ArcGIS.Runtime.Tasks.Query query = new ESRI.ArcGIS.Runtime.Tasks.Query()
            {
                ReturnGeometry = false,
                Where = "1=1"
            };
            query.OutFields.Add("STATE_NAME");

            try
            {
                var result = await queryTask.ExecuteAsync(query);
                QueryComboBox.ItemsSource = result.FeatureSet.Features;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #6
0
        private async Task RunQuery()
        {
            QueryTask queryTask =
                new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));

            ESRI.ArcGIS.Runtime.Tasks.Query query = new ESRI.ArcGIS.Runtime.Tasks.Query();
            query.Text = StateNameTextBox.Text;

            query.OutFields.Add("*");
            try
            {
                var result = await queryTask.ExecuteAsync(query);
                ResultGrid.ItemsSource = result.FeatureSet.Features;
            }
            catch (TaskCanceledException taskCanceledEx)
            {
                System.Diagnostics.Debug.WriteLine(taskCanceledEx.Message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #7
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Uri myUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/3");
            ESRI.ArcGIS.Runtime.Tasks.QueryTask myQueryTask = new ESRI.ArcGIS.Runtime.Tasks.QueryTask(myUri);

            List<string> myListOfString = new List<string>();
            myListOfString.Add("state_name");

            ESRI.ArcGIS.Runtime.Tasks.Query myQuery = new ESRI.ArcGIS.Runtime.Tasks.Query();
            myQuery.GroupByFieldsForStatistics = myListOfString;

            List<ESRI.ArcGIS.Runtime.Tasks.OutStatistic> myListOfOutStatistic =
                new List<ESRI.ArcGIS.Runtime.Tasks.OutStatistic>();

            ESRI.ArcGIS.Runtime.Tasks.OutStatistic myOutStatistic1 = new ESRI.ArcGIS.Runtime.Tasks.OutStatistic();
            myOutStatistic1.OnStatisticField = "pop2000";
            myOutStatistic1.OutStatisticFieldName = "StatePopulation";
            myListOfOutStatistic.Add(myOutStatistic1);

            ESRI.ArcGIS.Runtime.Tasks.OutStatistic myOutStatistic2 = null;
            myOutStatistic2 = new ESRI.ArcGIS.Runtime.Tasks.OutStatistic("state_name", "NumberOfCounties",
                ESRI.ArcGIS.Runtime.Tasks.StatisticType.Count);
            myListOfOutStatistic.Add(myOutStatistic2);

            ESRI.ArcGIS.Runtime.Tasks.OrderByField myOrderByField = new ESRI.ArcGIS.Runtime.Tasks.OrderByField();
            myOrderByField.Field = "state_name";
            myOrderByField.SortOrder = ESRI.ArcGIS.Runtime.Tasks.SortOrder.Descending;
            List<ESRI.ArcGIS.Runtime.Tasks.OrderByField> myOrderByFieldsList =
                new List<ESRI.ArcGIS.Runtime.Tasks.OrderByField>();
            myOrderByFieldsList.Add(myOrderByField);
            myQuery.OrderByFields = myOrderByFieldsList;

            myQuery.OutStatistics = myListOfOutStatistic;

            try
            {
                ESRI.ArcGIS.Runtime.Tasks.QueryResult myQueryResult = await myQueryTask.ExecuteAsync(myQuery);
                if (myQueryResult.FeatureSet.Features != null && myQueryResult.FeatureSet.Features.Count > 0)
                {
                    ESRI.ArcGIS.Runtime.FeatureSet theFeatureSet = myQueryResult.FeatureSet;
                    System.Collections.Generic.IList<ESRI.ArcGIS.Runtime.Graphic> theIReadOnlyListOfgraphic =
                        theFeatureSet.Features;
                    System.Text.StringBuilder theStringBuilder = new System.Text.StringBuilder();
                    foreach (ESRI.ArcGIS.Runtime.Graphic oneGraphic in theIReadOnlyListOfgraphic)
                    {
                        System.Collections.Generic.IDictionary<string, object> theIDictionaryOfString_Object =
                            oneGraphic.Attributes;
                        System.Collections.Generic.ICollection<string> theKeys = theIDictionaryOfString_Object.Keys;
                        foreach (string oneKey in theKeys)
                        {
                            if (theIDictionaryOfString_Object[oneKey] != null)
                            {
                                object theValue = theIDictionaryOfString_Object[oneKey];
                                string theValueAsString = theValue.ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }