Пример #1
0
        public void busServiceModel_LocationForAddress_Completed(object sender, EventArgs.LocationForAddressEventArgs e)
        {
            Debug.Assert(e.error == null);

            LocationForQuery location;

            if (e.locations.Count > 1)
            {
                location = e.locations[0];
                foreach (LocationForQuery l in e.locations)
                {
                    // If the candidate is a higher confidence than the
                    // current selected location, pick it instead
                    if (l.confidence < location.confidence)
                    {
                        location = l;
                    }
                    // The candidate doesn't have a higher confidence, so confirm that it
                    // is the same confidence, and then select whichever one is closest to Seattle
                    else if (l.confidence == location.confidence &&
                             l.location.GetDistanceTo(e.searchNearLocation) <
                             location.location.GetDistanceTo(e.searchNearLocation))
                    {
                        location = l;
                    }
                }
            }
            else if (e.locations.Count == 1)
            {
                location = e.locations[0];
            }
            else
            {
                location = null;
            }

            SearchByAddress_Callback callback = (SearchByAddress_Callback)e.state;

            callback(location, e.error);

            operationTracker.DoneWithOperation("SearchByAddress");
        }
Пример #2
0
        public void SearchByAddress(string addressString, SearchByAddress_Callback callback)
        {
            operationTracker.WaitForOperation("SearchByAddress", string.Format("Searching for location '{0}'...", addressString));

            locationModel.LocationForAddress(addressString, locationTracker.CurrentLocationSafe, callback);
        }
        public void SearchByAddress(string addressString, SearchByAddress_Callback callback)
        {
            operationTracker.WaitForOperation("SearchByAddress", string.Format("Searching for location '{0}'...", addressString));

            locationModel.LocationForAddress(addressString, locationTracker.CurrentLocationSafe, callback);
        }