Ejemplo n.º 1
0
        private void UpdateRoute(TripMapView mapView)
        {
            if (mapView == null || mapView.Route == null || mapView.Route.Count == 0)
            {
                return;
            }

            if (_routePath == null)
            {
                _routePath = new MutablePath();
            }
            else
            {
                _routePath.RemoveAllCoordinates();
            }

            var curvePoints = CurveApproxHelper.DouglasPeuckerReduction(mapView.Route.ToList(), 0.00001);

            curvePoints.ForEach(x => _routePath.AddLatLon(x.Latitude, x.Longitude));

            if (mapView.CurrentLocation != null)
            {
                _routePath.AddLatLon(mapView.CurrentLocation.Latitude, mapView.CurrentLocation.Longitude);
            }

            if (_routePolyline != null)
            {
                _routePolyline.Map = null;
                _routePolyline.Dispose();
            }

            _routePolyline = new Polyline
            {
                Path        = _routePath,
                StrokeWidth = 5f,
                StrokeColor = _pathColor
            };

            _routePolyline.Map = _control;

            _control.CameraTargetBounds = new CoordinateBounds(_routePath);
        }