internal PoiViewItem GetNearestPoi(GpsLocation loc, IGpsUtilities iGpsUtilities) { var candidates = GetItems(loc, 0.2); List <PoiViewItem> items = new PoiViewItemList(candidates, loc, iGpsUtilities); var item = items.OrderBy(x => x.GpsLocation.Distance).FirstOrDefault(); return(item); }
public void FilterPlaces(string name, PoiCountry?country, PoiCategory?category) { Task.Run(() => { IEnumerable <Poi> poiList; if (!string.IsNullOrEmpty(name) || country.HasValue || category.HasValue) { poiList = AppContext.Database.FindItems(name, category, country, false); } else { poiList = new List <Poi>(); } IEnumerable <PoiViewItem> items = new PoiViewItemList(poiList, _centerGpsLocation ?? AppContext.MyLocation, _iGpsUtilities); items = (_sortBy == SortBy.Name) ? items.OrderBy(x => x.Poi.Name) : items.OrderBy(x => x.GpsLocation.Distance); MainThread.BeginInvokeOnMainThread(() => _adapter.SetItems(items)); }); }