Esempio n. 1
0
        private async void DrawRoute(RouteDirectionDto routeDirectionDto)
        {
            map.Pins.Clear();
            map.MapElements.Clear();

            var steps = ProcessRouteResult(routeDirectionDto);

            Xamarin.Forms.Maps.Polyline polyline = new Xamarin.Forms.Maps.Polyline()
            {
                StrokeWidth = 6,
                StrokeColor = Color.FromHex("#1BA1E2")
            };

            foreach (var coordinates in steps)
            {
                var position = new Position(coordinates.Latitude, coordinates.Longitude);
                polyline.Geopath.Add(position);
            }

            map.MapElements.Add(polyline);

            map.Pins.Add(new Pin()
            {
                Position = polyline.Geopath.First(),
                Label    = "Origin",
                Type     = PinType.SavedPin
            });

            map.Pins.Add(new Pin()
            {
                Position = polyline.Geopath.Last(),
                Label    = "Destination",
                Type     = PinType.SavedPin
            });
        }
Esempio n. 2
0
        private List <Location> ProcessRouteResult(RouteDirectionDto result)
        {
            var routeCoordinates = GooglePolylineConverter.Decode(result.routes.FirstOrDefault().overview_polyline.points.ToString()).ToList();

            return(routeCoordinates);
        }