Пример #1
0
        private async void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            MapSuggestionItem selected = args.SelectedItem as MapSuggestionItem;

            chosenSuggestion = selected.name;
            mapLocationPoint = selected.point;
            await MapControlLocation.TrySetViewAsync(mapLocationPoint, 15D);
        }
Пример #2
0
        public static async Task <List <MapSuggestionItem> > getMapSuggestionsAsync(String query, Geopoint hintPoint)
        {
            List <MapSuggestionItem> locations = new List <MapSuggestionItem>();
            MapLocationFinderResult  result    = await MapLocationFinder.FindLocationsAsync(query, hintPoint, 20);

            if (result.Status != MapLocationFinderStatus.Success)
            {
                return(locations);
            }

            foreach (var location in result.Locations)
            {
                if (location.Address.Country == null || !location.Address.Country.Equals("Canada"))
                {
                    continue;
                }

                MapSuggestionItem suggestion = new MapSuggestionItem();
                string            text       = "";

                if (location.Address.StreetNumber != null && location.Address.StreetNumber.Length > 0)
                {
                    text += location.Address.StreetNumber;
                }

                if (location.Address.Street != null && location.Address.Street.Length > 0)
                {
                    if (text.Length > 0)
                    {
                        text += " ";
                    }
                    text += location.Address.Street;
                }

                if (location.Address.Neighborhood != null && location.Address.Neighborhood.Length > 0)
                {
                    if (text.Length > 0)
                    {
                        text += ", ";
                    }
                    text += location.Address.Neighborhood;
                }

                if (location.Address.Town != null && location.Address.Town.Length > 0)
                {
                    if (text.Length > 0)
                    {
                        text += ", ";
                    }
                    text += location.Address.Town;
                }

                if (text.Length == 0)
                {
                    text = location.Address.FormattedAddress;
                }

                suggestion.name  = text;
                suggestion.point = location.Point;
                locations.Add(suggestion);
            }

            return(locations);
        }