コード例 #1
0
        private void FindWebMapsButton_Click(object sender, RoutedEventArgs e)
        {
            webmapGraphicsLayer.Graphics.Clear();

            // Search envelope must be in geographic (WGS84).  Convert the current map extent from Web Mercator
            // to geographic.
            ESRI.ArcGIS.Client.Geometry.Geometry geom = mercator.ToGeographic(MyMap.Extent);

            SpatialSearchParameters parameters = new SpatialSearchParameters
            {
                Limit        = String.IsNullOrEmpty(resultLimit.Text) == true ? 15 : Convert.ToInt32(resultLimit.Text),
                SearchExtent = geom.Extent,
                QueryString  = String.Format("{0} And type:Web Map", searchText.Text)
            };

            arcgisPortal.SearchItemsAsync(parameters, (result, error) =>
            {
                if (error == null)
                {
                    // Set the ItemsSource for the Listbox to an IEnumerable of ArcGISPortalItems.
                    // Bindings setup in the Listbox item template in XAML will enable the discovery and
                    // display individual result items.
                    WebMapsListBox.ItemsSource = result.Results;

                    // For each web map returned, add the center (point) of the web map extent as a graphic.
                    // Add the ArcGISPortalItem instance as an attribute.  This will be used to select graphics
                    // in the map.
                    foreach (var item in result.Results)
                    {
                        Graphic graphic = new Graphic();
                        graphic.Attributes.Add("PortalItem", item);
                        MapPoint extentCenter = item.Extent.GetCenter();
                        graphic.Geometry      = new MapPoint(extentCenter.X, extentCenter.Y, new SpatialReference(4326));
                        webmapGraphicsLayer.Graphics.Add(graphic);
                    }
                }
            });
        }
コード例 #2
0
        private void FindWebMapsButton_Click(object sender, RoutedEventArgs e)
        {
            webmapGraphicsLayer.ClearGraphics();

            // Search envelope must be in geographic (WGS84).  Convert the current map extent from Web Mercator
            // to geographic.
            ESRI.ArcGIS.Client.Geometry.Geometry geom = mercator.ToGeographic(MyMap.Extent);

            SpatialSearchParameters parameters = new SpatialSearchParameters
            {
                Limit = String.IsNullOrEmpty(resultLimit.Text) == true ? 15 : Convert.ToInt32(resultLimit.Text),
                SearchExtent = geom.Extent,
                QueryString = String.Format("{0} And type:Web Map", searchText.Text)
            };

            arcgisPortal.SearchItemsAsync(parameters, (result, error) =>
            {
                if (error == null)
                {
                    // Set the ItemsSource for the Listbox to an IEnumerable of ArcGISPortalItems.
                    // Bindings setup in the Listbox item template in XAML will enable the discovery and
                    // display individual result items.
                    WebMapsListBox.ItemsSource = result.Results;

                    // For each web map returned, add the center (point) of the web map extent as a graphic.
                    // Add the ArcGISPortalItem instance as an attribute.  This will be used to select graphics
                    // in the map.
                    foreach (var item in result.Results)
                    {
                        Graphic graphic = new Graphic();
                        graphic.Attributes.Add("PortalItem", item);
                        MapPoint extentCenter = item.Extent.GetCenter();
                        graphic.Geometry = new MapPoint(extentCenter.X, extentCenter.Y, new SpatialReference(4326));
                        webmapGraphicsLayer.Graphics.Add(graphic);
                    }
                }
            });
        }