public async void SuggestForSearch(string searchExpression)
 {
     await AppCore.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate
     {
         if (SearchResults == null)
         {
             SearchResults = new ObservableCollection <PlaceAutoComplete.Prediction>();
         }
         SearchResults.Clear();
         var saved = SavedPlacesVM.GetSavedPlaces();
         saved     = saved.Where(x => x.PlaceName.Contains(searchExpression)).ToList();
         foreach (var item in saved)
         {
             SearchResults.Add(new PlaceAutoComplete.Prediction()
             {
                 place_id = $"{item.Latitude},{item.Longitude}", description = "Saved:" + item.PlaceName
             });
         }
         if (await SettingsSetters.GetAccessToContcts())
         {
             var contacts = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly);
             if (contacts != null)
             {
                 var search = await contacts.FindContactsAsync(searchExpression);
                 var res    = search.Where(x => x.Addresses.Count > 0);
                 foreach (var item in res)
                 {
                     var cadd = item.Addresses.FirstOrDefault();
                     SearchResults.Add(new PlaceAutoComplete.Prediction()
                     {
                         description = "Contacts:" + item.Name, place_id = $"{cadd.StreetAddress}, {cadd.Locality}"
                     });
                 }
             }
         }
         if (searchExpression.Length >= 3)
         {
             var s = await PlaceAutoComplete.GetAutoCompleteResults(searchExpression, location: MapView.MapControl.Center, radius: 50000);
             if (s == null)
             {
                 return;
             }
             foreach (var item in s.predictions)
             {
                 SearchResults.Add(item);
             }
         }
     });
 }
示例#2
0
 public async void Search()
 {
     await AppCore.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate
     {
         SearchResults.Clear();
         var s = await PlaceAutoComplete.GetAutoCompleteResults(SearchQuery, location: MapView.MapControl.Center, radius: 50000);
         if (s == null)
         {
             return;
         }
         foreach (var item in s.predictions)
         {
             SearchResults.Add(item);
         }
     });
 }
 public async void SuggestForSearch(string searchExpression)
 {
     await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate
     {
         SearchResults.Clear();
         var s = await PlaceAutoComplete.GetAutoCompleteResults(searchExpression, location: MapView.MapControl.Center, radius: 50000);
         if (s == null)
         {
             return;
         }
         foreach (var item in s.predictions)
         {
             SearchResults.Add(item);
         }
     });
 }