private async Task GetUserHives(string uid) { if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await _pageDialogService.DisplayAlertAsync("No Internet", "Please check your internet connection and try again.", "Ok"); return; } var userHives = await _firebaseHelper.GetAllUserHives(uid); if (Pins.Any()) { Pins.Clear(); } foreach (var hive in userHives) { Pins.Add(new Pin() { Label = hive.HiveName, Position = new Position(hive.HiveLocation.Latitude, hive.HiveLocation.Longitude), Icon = BitmapDescriptorFactory.FromBundle("map_pin.png"), IsDraggable = true }); } }
private void ULPins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { Pushpin[] temp = this.Children.Cast <object>().Where(p => p is Pushpin).Cast <Pushpin>().ToArray().Clone() as Pushpin[]; if (e.OldItems != null) { //foreach (UserLocation ul in e.OldItems) // this.Children.Remove(temp.FirstOrDefault(p => p.ToolTip == ul.Name)); clearPins(); foreach (var pin in temp) { if (e.OldItems.Cast <UserLocation>().Any(p => p.Name == (string)((ToolTip)pin?.ToolTip)?.Content)) { continue; } Pushpin np = new Pushpin() { Location = pin.Location, Content = pin.Content }; np.ToolTip = pin.ToolTip; this.Children.Add(np); } } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { foreach (Pushpin pin in temp) { if (!Pins?.Any(p => p.Location == pin.Location) ?? false) { this.Children.Remove(pin); } } } //Add the new pushpins if (e.NewItems != null) { foreach (UserLocation ul in e.NewItems) { Pushpin np = new Pushpin() { Location = ul.Pin.Location, Content = Tools.CreateIcon(MaterialDesignThemes.Wpf.PackIconKind.Star) }; np.ToolTip = Tools.CreateTootip(ul.Name); this.Children.Add(np); } } this.UpdateLayout(); }
public void UpsertPin(Pin pPin) { // TODO make this cleaner bool doesPinExist = Pins.Any(pin => pin.PinId == pPin.PinId); if (!doesPinExist) { Pins.Add(pPin); } else { Pins[Pins.FindIndex(pin => pin.PinId == pPin.PinId)] = pPin; } }
public bool HasExecutePins() { return(Pins.Any(x => x.WrappedType == typeof(NodePinTypeExecute))); }
public Page2ViewModel() { _inInfoWindowsClickCommand = new Command <IMapPin>(pin => Debug.WriteLine($"The Pin {pin.Title} Info Window has been click")); _changeMapTypeCommand = new Command <MapType>(m => MapDisplayType = m); _addPinCommand = new Command(AddPin, o => _allPins.Any()); _removePinCommand = new Command(RemovePin, o => Pins.Any()); _moveToRegionCommand = new Command(() => Map.MoveToRegion(new MapRegion(new Position(47.389097, 8.517756), 400))); _addPolylineCommand = new Command(AddPolyline, o => _allPolylines.Any()); _removePolylineCommand = new Command(RemovePolyline, o => Overlays.Any()); _selectCommand = new Command <int>(SetSelectedItem, (arg) => Pins.Count > 0); _clearSelectionCommand = new Command(() => SelectedItem = null); _moveToUserLocationcommand = new Command(() => Map.MoveToUserLocation(false)); _visibleRegionChangedCommand = new Command <MapRegion>((region) => RegionChanged(region)); _allPins = new LinkedList <IMapPin>( new[] { new MapPin { Title = "Brändlen", Location = new Position(46.904829, 8.409724), Color = Color.Red }, new MapPin { Title = "Wolfenschiessen", Snippet = "... nothing to see here", Location = new Position(46.905180, 8.398110), Color = Color.Blue }, new MapPin { Title = "Klewenalp", Location = new Position(46.939898, 8.475217), Color = Color.Fuchsia, }, new MapPin { Title = "Beckenried NW", Location = new Position(46.963876, 8.482078), Color = Color.Green, }, new MapPin { //Title = "Zürich", //Snippet = "It's awesome", Location = new Position(47.3667, 8.5500), Image = "pin_icon", SelectedImage = "pin_icon_active", Anchor = new Point(0.5, 1) }, new MapPin { Title = "fivenine", Snippet = "fivenine GmbH", Location = new Position(47.389097, 8.517756), Image = "pin_icon", SelectedImage = "pin_icon_active", Anchor = new Point(0.5, 1), Draggable = true }, }); Pins = new ObservableCollection <IMapPin>(); _allPolylines = new LinkedList <IMapOverlay>(); var polyline = new PolylineOverlay(); foreach (var pin in _allPins) { polyline.Add(pin.Location); } _allPolylines.AddLast(polyline); Overlays = new ObservableCollection <IMapOverlay>(); Overlays.Add(new CircleOverlay { Location = new Position(47.389097, 8.517756), Radius = 400, Color = Color.Navy.MultiplyAlpha(0.2), FillColor = Color.Blue.MultiplyAlpha(0.2) }); // Add some sample pins AddPin(null); AddPin(null); // Add some polylines AddPolyline(null); SelectedItem = Pins.LastOrDefault(); }