Esempio n. 1
0
 public MapAddPin(BasicGeoposition position)
 {
     InitializeComponent();
     Pin = new MyPin
     {
         Coordinate = new Coordinate(position.Latitude, position.Longitude)
     };
     RadioButtonClick = new Command(OnRadioButtonClick);
 }
        private void OnPinSelected(MyPin newPin, MyPin oldPin)
        {
            if (oldPin != null)
            {
                OnRemovePin(oldPin.Coordinate);
                OnAddPin(oldPin);
            }

            if (newPin == null)
            {
                return;
            }
            OnRemovePin(newPin.Coordinate);
            OnAddPin(newPin);
        }
Esempio n. 3
0
        private async void adicionarMarcadores()
        {
            var items = await GetParksAsync();

            foreach (var item in items)
            {
                var pin = new MyPin()
                {
                    Position = new Position(item.Latitude, item.Longitude),
                    Label    = item.Name,
                    Park     = item
                };

                mapVisualizacao.Pins.Add(pin);
                pin.Clicked += Clicked_Marker;
            }
        }
        private void OnAddPin(MyPin pin)
        {
            var pinPosition = new BasicGeoposition
            {
                Latitude  = pin.Coordinate.Latitude,
                Longitude = pin.Coordinate.Longitude
            };
            var pinPoint = new Geopoint(pinPosition);
            var mapIcon  = new MapIcon
            {
                Image = RandomAccessStreamReference.CreateFromUri(new Uri($"ms-appx:///{pin.IconPath}")),
                CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible,
                Location = pinPoint,
                NormalizedAnchorPoint = new Point(0.5, 1.0),
                Title = pin.Label
            };

            _nativeMap.MapElements.Add(mapIcon);
        }
        private void OnTypeSelected(MyPin pin)
        {
            switch (pin.MyType)
            {
            case MyPinType.Start when _pins.Pins.StartPin.Coordinate != null:
                Application.Current.MainPage.DisplayAlert("Error", "You can`t add more then 1 start point", "Ok");
                return;

            case MyPinType.End when _pins.Pins.EndPin.Coordinate != null:
                Application.Current.MainPage.DisplayAlert("Error", "You can`t add more then 1 end point", "Ok");
                return;
            }

            _pins.AddPin(pin);

            var window = _nativeMap.Children.FirstOrDefault(el => el is MapAddPin);

            if (window != null)
            {
                _nativeMap.Children.Remove(window);
            }
        }
        private void OnActionSelected(MapIcon pin, PinAction action)
        {
            switch (action)
            {
            case PinAction.Delete:
                var myPin = new MyPin
                {
                    Coordinate = new Coordinate(pin.Location.Position.Latitude, pin.Location.Position.Longitude),
                    MyType     = MyPinType.Undefined
                };
                _pins.RemovePin(myPin);

                var window = _nativeMap.Children.FirstOrDefault(el => el is PinInfo);
                if (window != null)
                {
                    _nativeMap.Children.Remove(window);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }