public async Task <bool> ShowFriendsOnMap(ToggleSwitch toggleSwitch, Pushpin userPin) { const int myEntityId = 1; var furthestAwayFriend = 1.0; var switchName = toggleSwitch.Content.ToString(); var layerName = toggleSwitch.LayerName(); toggleSwitch.Opacity = 0.8; var tagLayer = this.FindOrAddLayerByName(layerName); var results = await Discovr.Classes.Core.LocationEntity.GetFriends(myEntityId, switchName); if (results != null) { ClearLayer(tagLayer); var pointToCompareTo = userPin != null && userPin.GeoCoordinate != null ? userPin.GeoCoordinate : MainMap.Center; var newColor = Extensions.GetRandomColor(); toggleSwitch.SwitchForeground = newColor; foreach (var result in results) { var distanceToFriend = Map.AddOrUpdatePinToLayer(pointToCompareTo, new GeoCoordinate(result.Latitude, result.Longitude), result.EntityLabel, result.AvatarUrl, tagLayer, true, null, newColor, new AppSettings().ShowMetric); furthestAwayFriend = distanceToFriend > furthestAwayFriend ? distanceToFriend : furthestAwayFriend; } MainMap.ZoomLevel = GeoConverter.GetZoomLevelFromMeters(furthestAwayFriend); toggleSwitch.Opacity = 1; } return(true); }