Exemplo n.º 1
0
        async void Update(Xamarin.Forms.GoogleMaps.Position position)
        {
            if (Pins.Count == 1 && Polylines != null && Polylines?.Count > 1)
            {
                return;
            }

            var cPin = Pins.FirstOrDefault();

            if (cPin != null)
            {
                cPin.Position = new Position(position.Latitude, position.Longitude);
                cPin.Icon     = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_taxi.png") : BitmapDescriptorFactory.FromView(new Image()
                {
                    Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25
                });

                await MoveCamera(CameraUpdateFactory.NewPosition(new Position(position.Latitude, position.Longitude)));

                var previousPosition = Polylines?.FirstOrDefault()?.Positions?.FirstOrDefault();
                Polylines?.FirstOrDefault()?.Positions?.Remove(previousPosition.Value);
            }
            else
            {
                //END TRIP
                Polylines?.FirstOrDefault()?.Positions?.Clear();
            }
        }
Exemplo n.º 2
0
        public void UpdateRouteView(Route route)
        {
            var locationCollection = new LocationCollection();

            foreach (var segment in route.Segments)
            {
                var point = segment.Figure.Points.First();
                locationCollection.Add(new Location()
                {
                    Latitude  = RadianToDegree(point.Latitude),
                    Longitude = RadianToDegree(point.Longitude)
                }
                                       );
            }
            Polylines.FirstOrDefault().Locations = locationCollection;
        }