コード例 #1
0
        private void FindButton_Click(object sender, RoutedEventArgs e)
        {
            MyInfoWindow.IsOpen = false;
            FindResultLocationsGraphicsLayer.Graphics.Clear();

            // If locator already processing a request, cancel it.  Note, the request is not cancelled on the server.
            if (_locatorTask.IsBusy)
            {
                _locatorTask.CancelAsync();
            }

            // If search text is empty, return
            if (string.IsNullOrEmpty(SearchTextBox.Text))
            {
                return;
            }

            // In this sample, the center of the map is used as the location from which results will be ranked and distance calculated.
            // The distance from the location is optional.  Specifies the radius of an area around a point location which is used to boost
            // the rank of geocoding candidates so that candidates closest to the location are returned first. The distance value is in meters.
            LocatorFindParameters locatorFindParams = new LocatorFindParameters()
            {
                Text                = SearchTextBox.Text,
                Location            = MyMap.Extent.GetCenter(),
                Distance            = MyMap.Extent.Width / 2,
                MaxLocations        = 5,
                OutSpatialReference = MyMap.SpatialReference
            };

            locatorFindParams.OutFields.AddRange(new string[] { "PlaceName", "City", "Region", "Country", "Score", "Distance", "Type" });

            _locatorTask.FindAsync(locatorFindParams);
        }
コード例 #2
0
        private void GetDirections_Click(object sender, RoutedEventArgs e)
        {
            //Reset
            DirectionsStackPanel.Children.Clear();
            _stops.Clear();

            (MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer).Graphics.Clear();
            _locator.CancelAsync();
            _routeTask.CancelAsync();

            //Geocode from address
            _locator.FindAsync(ParseSearchText(FromTextBox.Text), "from");
        }