Пример #1
0
        public void DrawPath(IEnumerable <GeoPoint> path, IEnumerable <Pin> pins = null, GeoPoint center = null, double distance = 1.0, bool clear = true)
        {
            if (clear)
            {
                RouteCoordinates.Clear();
            }
            var cor = path.Select(x => new Position(x.Lat, x.Lon));

            RouteCoordinates.AddRange(cor);

            Pins.Clear();

            if (pins != null)
            {
                foreach (var p in pins.Where(x => x != null))
                {
                    Pins.Add(p);
                }
            }

            if (center != null)
            {
                MoveToRegion(MapSpan.FromCenterAndRadius(center, Distance.FromMiles(distance)));
            }
        }
Пример #2
0
 private void ClearPolygon(object obj)
 {
     Pins.Clear();
     Polylines.Clear();
     Polygons.Clear();
     _allowedToAddPoint = true;
 }
Пример #3
0
 private void FavAddressSearch_OnSelectedAction(object sender, EventArgs e)
 {
     if (sender is AddressesSearch asS)
     {
         if (asS.SelectedAddress == null)
         {
             return;
         }
         var currPin = Pins?.FirstOrDefault();
         if (currPin != null)
         {
             Pins.Clear();
             currPin.Location = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon);
             Pins.Add(currPin);
         }
         else
         {
             if (!Locations.Any(p => p.Address == asS.SelectedAddress))
             {
                 Pins.Clear();
                 Pins.Add(new Pushpin()
                 {
                     Location = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon), Content = Tools.CreateIcon((Editing == null) ? PackIconKind.Plus : PackIconKind.Edit)
                 });
             }
         }
         if (!(currPin != null && (Math.Abs(currPin.Location.Latitude - asS.SelectedAddress.Lat) < 1 || Math.Abs(currPin.Location.Longitude - asS.SelectedAddress.Lon) < 1)))
         {
             FavMap.Center = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon);
         }
     }
 }
Пример #4
0
        private void OnPinClicked(TKCustomMapPin pin)
        {
            var firstPosition = Pins.First().Position;
            var position      = pin.Position;

            // if the user tapped the first marker, we'll close the gap.
            // and prevent them from adding more points.
            _allowedToAddPoint = _allowedToAddPoint &&
                                 Pins.Count > 1 &&
                                 !(Math.Abs(position.Latitude - firstPosition.Latitude) <= 0 && Math.Abs(position.Longitude - firstPosition.Longitude) <= 0);

            if (!_allowedToAddPoint)
            {
                var polygon = new TKPolygon
                {
                    Color       = Color.FromHex("#7f000000"),
                    StrokeColor = Color.Black,
                    StrokeWidth = 2
                };
                foreach (var line in Polylines)
                {
                    polygon.Coordinates.AddRange(line.LineCoordinates);
                }
                Polylines.Clear();
                Polygons.Clear();
                Pins.Clear();
                Polygons.Add(polygon);
            }
        }
Пример #5
0
        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
                });
            }
        }
Пример #6
0
        private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                Pins.Clear();
            }

            if (e.OldItems != null)
            {
                foreach (CustomPin pin in e.OldItems)
                {
                    Pins.Remove(pin.Pin);
                    pin.Pin.PropertyChanged -= OnPropertyChanged;
                }
            }

            if (e.NewItems != null)
            {
                foreach (CustomPin pin in e.NewItems)
                {
                    Pins.Add(pin.Pin);
                    pin.Pin.PropertyChanged += OnPropertyChanged;
                }
            }
        }
Пример #7
0
 public void Clear()
 {
     if (Device.OS == TargetPlatform.iOS)
     {
         Pins.Clear();
     }
     CustomPins.Clear();
 }
Пример #8
0
 /// <summary>
 /// Unpins the managed arrays, to be paired with calls to Pin()
 /// </summary>
 public void Unpin()
 {
     foreach (var pin in Pins.Values)
     {
         pin.Free();
     }
     Pins.Clear();
 }
Пример #9
0
 private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     // We should be able to just replace the changed pin, but rebuild is required to force map refresh
     Pins.Clear();
     foreach (var pin in Items)
     {
         Pins.Add(pin.Pin);
     }
 }
Пример #10
0
 /// <summary>
 /// Clears the pins.
 /// </summary>
 public void ClearPins()
 {
     Pins.Clear();
     ClearSequences();
     ClearMeasurementCombinations();
     if (OnPinsUpdated != null)
     {
         OnPinsUpdated.Invoke(this, new ControllerPinUpdateArgs(null, UpdateOperation.Clear, null));
     }
 }
Пример #11
0
 /// <summary>
 /// Must call this method to remove CirlcePin objects. Otherwise, overlays would not be removed.
 /// </summary>
 public void ClearCirclePins()
 {
     if (Pins.Count > 0)
     {
         var circlePins = new CirclePin[Pins.Count];
         Pins.CopyTo(circlePins, 0);
         Pins.Clear();
         PinsCleared?.Invoke(this, circlePins);
     }
 }
Пример #12
0
        private void CenteredPinMap_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (VisibleRegion != null)
            {
                centeredPin.Position = ((CenteredPinMap)sender).VisibleRegion.Center;

                Pins.Clear();
                Pins.Add(centeredPin);
            }
        }
Пример #13
0
 public void UpdatePins(IEnumerable <IMapModel> items)
 {
     Pins.Clear();
     Items.Clear();
     foreach (var item in items)
     {
         Items.Add(item);
         Pins.Add(item.AsPin());
     }
 }
Пример #14
0
        // ===========================================================================
        // = Public Methods
        // ===========================================================================

        public void RefreshPins()
        {
            Pins.Clear();

            foreach (var item in ItemsSource.Cast <ExtendedPin>())
            {
                Pins.Add(item.AsPin());
            }

            RaisePinsChanged();
        }
Пример #15
0
 public override void Unserialize(BinaryReader reader)
 {
     Name      = reader.ReadString();
     X         = reader.ReadSingle();
     Y         = reader.ReadSingle();
     Direction = (Direction)reader.ReadInt32();
     Pins.Clear();
     Pin = new G_Pin(this, "");
     Pin.Unserialize(reader);
     Pins.Add(Pin);
 }
Пример #16
0
        public void UpdatePins()
        {
            Pins?.Clear();
            var coordinates = Locations?.Select(x => x.Position);
            int i           = 1;

            coordinates?.ForEach(x => Pins.Add(new Pin()
            {
                Position = x, Label = i++.ToString()
            }));
        }
Пример #17
0
 /// <summary>
 /// Unloads the dialog: it first calls the <see cref="ILoadable.Unload"/> function of all the nodes implementing the
 /// <see cref="ILoadable"/> interface. Then, it clears the nodes and the pins maps.
 /// </summary>
 public void Unload()
 {
     foreach (WireNode node in NodesDictionary.Values)
     {
         if (node is ILoadable)
         {
             (node as ILoadable).Unload();
         }
     }
     NodesDictionary.Clear();
     Pins.Clear();
 }
        private void OnMapClicked(Position position)
        {
            string title       = "my location";
            var    existingPin = Pins.FirstOrDefault();

            if (existingPin != null)
            {
                title = existingPin.Title;
            }
            Pins.Clear(); //TODO: Add PinSelectionMode.Single / Multiple
            AddPin(position, title);
        }
Пример #19
0
        private async Task LoadPinsFromDataBase()
        {
            Pins.Clear();
            var PinModels = (await _pinService.GetPinsAsync(App.CurrentUserId)).Where(x => x.IsFavorite == true);

            if (PinModels != null)
            {
                foreach (PinModel model in PinModels)
                {
                    Pins.Add(model.ToPin());
                }
            }
        }
        public void SetGeolotation(string name, string address, double latitude, double longitude)
        {
            Pins.Clear();
            var position = new Position(latitude, longitude);
            var pin      = new Pin
            {
                Type     = PinType.Place,
                Position = position,
                Label    = name,
                Address  = address,
            };

            Pins.Add(pin);
        }
Пример #21
0
        public async Task Initialize()
        {
            Pins.Clear();

            Pins.Add(new Pin("Port 1", 4));
            Pins.Add(new Pin("Port 2", 5));
            Pins.Add(new Pin("Port 3", 6));
            Pins.Add(new Pin("Port 4", 26));

            foreach (var pin in Pins)
            {
                pin.State = await Client.GetPinAsync(pin.Id);
            }
        }
Пример #22
0
 //use OnListOfPinsChanged and remove OnPropertyChanged
 protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
 {
     if (propertyName == nameof(ListOfPins))
     {
         if (ListOfPins != null)
         {
             Pins.Clear();
         }
         foreach (var item in ListOfPins)
         {
             Pins.Add(item);
         }
     }
 }
Пример #23
0
 /// <summary>
 /// Called when any property changes.
 /// When VisibleRegion changes, move pin to new center.
 /// </summary>
 /// <param name="propertyName"></param>
 protected override void OnPropertyChanged(string propertyName = null)
 {
     base.OnPropertyChanged(propertyName);
     if (propertyName == "VisibleRegion")
     {
         var pin = new Pin()
         {
             Position = VisibleRegion.Center,
             Label    = "Auswahl"
         };
         Pins.Clear();
         Pins.Add(pin);
         PosSelection = VisibleRegion.Center;
     }
 }
Пример #24
0
 public override void Unserialize(BinaryReader reader)
 {
     Name      = reader.ReadString();
     Delay     = reader.ReadInt32();
     X         = reader.ReadSingle();
     Y         = reader.ReadSingle();
     Direction = (Direction)reader.ReadInt32();
     Pins.Clear();
     IN = new G_Pin(this, "");
     IN.Unserialize(reader);
     Pins.Add(IN);
     OUT = new G_Pin(this, "");
     OUT.Unserialize(reader);
     Pins.Add(OUT);
 }
Пример #25
0
        private async Task LoadPinsFromDataBaseAsync()
        {
            Pins.Clear();
            var MapPins = await _pinService.GetPinsAsync(App.CurrentUserId);

            ICommand TappedCommand = new Command(ToMapPagePin);

            if (MapPins != null)
            {
                foreach (var pin in MapPins)
                {
                    var PinView = pin.ToViewViewModel(TappedCommand);
                    Pins.Add(PinView);
                }
            }
        }
 private void CustomMap_MapClicked(object sender, MapClickedEventArgs e)
 {
     if (Pins.Count >= 1)
     {
         Pins.Clear();
     }
     else
     {
         GetPinPosition?.Execute(e.Point);
         var pin = new Pin()
         {
             Position = new Position(e.Point.Latitude, e.Point.Longitude),
             Label    = ""
         };
         this.Pins.Add(pin);
     }
 }
Пример #27
0
 /***METHODS PARKING**/
 public void SetGeolocationParqueaderos(ObservableCollection <ParqueaderoItemViewModel> parqueaderos)
 {
     Pins.Clear();
     foreach (var ip in parqueaderos)
     {
         PositionsSearch = new Position(ip.Latitud ?? 0, ip.Longitud ?? 0);
         var pin = new Pin
         {
             Type           = PinType.Place,
             Position       = PositionsSearch,
             Label          = ip.Nombre,
             Address        = ip.Direccion,
             BindingContext = ip,
         };
         Pins.Add(pin);
     }
 }
Пример #28
0
 protected override void OnPropertyChanged([CallerMemberName] string propertyName = "")
 {
     base.OnPropertyChanged(propertyName);
     if (propertyName == "Locations")
     {
         Pins.Clear();
         foreach (var item in Locations)
         {
             Pins.Add(new Pin(this)
             {
                 Label    = (Locations.IndexOf(item) + 1).ToString(),
                 Position = new Position(item.Latitude, item.Longitude),
                 Type     = PinType.Pin,
             });
         }
     }
 }
Пример #29
0
        public async Task GetMeetups()
        {
            Pins.Clear();

            var    Uri  = new Uri("https://server-cy3lzdr3na-uc.a.run.app/meetup/");
            string data = await RestService.Read(Uri);

            var    meetups = JsonConvert.DeserializeObject <List <Meetup> >(data);
            string id      = await SecureStorage.GetAsync("ID");

            meetups.RemoveAll(m => m.User1 != id && m.User2 != id);


            foreach (var meetup in meetups)
            {
                string id1   = meetup.User1;
                var    Uri1  = new Uri("https://server-cy3lzdr3na-uc.a.run.app/user/" + id1);
                string Data1 = await RestService.Read(Uri1);

                var users1 = JsonConvert.DeserializeObject <List <User> >(Data1);
                var User1  = users1.Find(user => user.Id == id1);

                var Pin1 = new Pin
                {
                    Position = new Position(User1.Latitude, User1.Longitude),
                    Label    = User1.Name
                };
                Pins.Add(Pin1);

                string id2   = meetup.User2;
                var    Uri2  = new Uri("https://server-cy3lzdr3na-uc.a.run.app/user/" + id2);
                string Data2 = await RestService.Read(Uri2);

                var users2 = JsonConvert.DeserializeObject <List <User> >(Data2);
                var User2  = users2.Find(user => user.Id == id2);

                var Pin2 = new Pin
                {
                    Position = new Position(User2.Latitude, User2.Longitude),
                    Label    = User2.Name
                };
                Pins.Add(Pin2);
            }
        }
Пример #30
0
 public override void Unserialize(BinaryReader reader)
 {
     GateType  = reader.ReadString();
     Name      = reader.ReadString();
     NameRoot  = reader.ReadString();
     X         = reader.ReadSingle();
     Y         = reader.ReadSingle();
     Direction = (Direction)reader.ReadInt32();
     Pins.Clear();
     IN_1 = new G_Pin(this, "");
     IN_1.Unserialize(reader);
     Pins.Add(IN_1);
     IN_2 = new G_Pin(this, "");
     IN_2.Unserialize(reader);
     Pins.Add(IN_2);
     OUT = new G_Pin(this, "");
     OUT.Unserialize(reader);
     Pins.Add(OUT);
 }