Beispiel #1
0
        void DrawRoute(DirectionsRoute route)
        {
            Java.Util.ArrayList points = new Java.Util.ArrayList();
            IList <Com.Mapbox.Geojson.Point> coords = LineString.FromPolyline(route.Geometry(), Constants.Precision6).Coordinates();

            foreach (Com.Mapbox.Geojson.Point point in coords)
            {
                points.Add(new LatLng(point.Latitude(), point.Longitude()));
            }

            if (points.IsEmpty == false)
            {
                if (polyline != null)
                {
                    mapboxMap.RemovePolyline(polyline);
                }

                // Draw polyline on map
                polyline = mapboxMap
                           .AddPolyline(new PolylineOptions()
                                        .AddAll(points)
                                        .InvokeColor(Color.ParseColor("#4264fb"))
                                        .InvokeWidth(5));
            }
        }
Beispiel #2
0
        //Clears all routes on the map
        public static void clearRoutes(MapboxMap map)
        {
            var polylines = map.Polylines;

            foreach (var polyline in polylines)
            {
                map.RemovePolyline(polyline);
            }
        }