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)); } }
private void DrawRoute(DirectionsRoute route) { List <LatLng> points = new List <LatLng>(); List <Point> coords = LineString.FromPolyline(route.Geometry(), Mapbox.Core.Constants.Constants.Precision6).Coordinates().ToList(); foreach (Point point in coords) { points.Add(new LatLng(point.Latitude(), point.Longitude())); } if (points.Any()) { if (polyline != null) { mapboxMap.RemovePolyline(polyline); } Java.Util.ArrayList all = new Java.Util.ArrayList(points); polyline = mapboxMap.AddPolyline(new PolylineOptions() .AddAll(all) .InvokeColor(Color.ParseColor(GetString(Resource.String.blue))) .InvokeWidth(5)); } }
public void BoundCameraToRoute() { if (route != null) { IList <Point> routeCoords = LineString.FromPolyline(route.Geometry(), Constants.Precision6).Coordinates(); var bboxPoints = new List <LatLng>(); foreach (Point point in routeCoords) { bboxPoints.Add(new LatLng(point.Latitude(), point.Longitude())); } if (bboxPoints.Count > 1) { try { LatLngBounds bounds = new LatLngBounds.Builder().Includes(bboxPoints).Build(); AnimateCameraBbox(bounds, CAMERA_ANIMATION_DURATION, new int[] { 50, 500, 50, 335 }); } catch (InvalidLatLngBoundsException exception) { Toast.MakeText(this, "Valid route not found.", ToastLength.Short).Show(); } } } }