public void FetchAndUpdateClosest() { BankEntity closestBankEntity = ViewModel.ClosestEntity ((this.Activity as BankEntityLocator).MapOptions); if (EntityClosestToUser != null && closestBankEntity.Equals (EntityClosestToUser)) return; if (closestBankEntity != null) { Activity.RunOnUiThread (() => { if(EntityClosestToUser != null) EntityClosestToUser.IconType = ViewModel.IconType; EntityMarker plottedEntity = LocationsPlottedOnMap.Find (e => e.Entity.LocationId == closestBankEntity.LocationId); if (plottedEntity != null) { EntityClosestToUser = plottedEntity; plottedEntity.IconType = IconType.Closest; } else { var marker = new EntityMarker (closestBankEntity, IconType.Closest); marker.AddMarkerTo (this.Map); EntityClosestToUser = marker; LocationsPlottedOnMap.Add (marker); } }); } }
private void UpdateViewWithEntities(List<BankEntity> entities) { List<BankEntity> plottedEntities = (from marker in LocationsPlottedOnMap select marker.Entity).ToList (); var entitiesToPlot = entities.Except (plottedEntities); Activity.RunOnUiThread (() => { foreach (BankEntity aEntity in entitiesToPlot) { var marker = new EntityMarker (aEntity, ViewModel.IconType); marker.AddMarkerTo (this.Map); LocationsPlottedOnMap.Add (marker); } }); }