private async Task SearchAsync(string what, string where) { var span = new MKCoordinateSpan(0.25, 0.25); var request = new MKLocalSearchRequest { NaturalLanguageQuery = what, Region = new MKCoordinateRegion(ParseCoordinates(where), span), }; var search = new MKLocalSearch(request); MKLocalSearchResponse response = null; try { response = await search.StartAsync(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } if (response != null) { searchItems = response.MapItems; PerformSegue(SearchSegueIdentifier, this); } }
private async Task <List <MKMapItem> > Search(string forSearchString, CancellationToken cancellationToken) { MKLocalSearchRequest request = new MKLocalSearchRequest(); request.NaturalLanguageQuery = forSearchString; MKLocalSearch search = new MKLocalSearch(request); try { cancellationToken.ThrowIfCancellationRequested(); MKLocalSearchResponse response = await search.StartAsync(); cancellationToken.ThrowIfCancellationRequested(); return(response.MapItems.ToList()); } catch { return(null); } }