public void CreateRouteBackground(List <LocationDTO> coordonates) { _controller.InvokeOnMainThread(() => { // Clean the map if (RoutePolyline != null) { MapViewControl.RemoveOverlay(RoutePolyline); } if (PointsOfRoute.Count > 0) { MapViewControl.RemoveAnnotations(PointsOfRoute.ToArray()); PointsOfRoute.Clear(); } if (SelectedPointsOfRoute != null) { MapViewControl.RemoveAnnotation(SelectedPointsOfRoute); } }); if (coordonates.Count != 0) { foreach (var coordonate in coordonates) { if (IsOutOf) { var trackingAnnotation = new TrackingAnnotation(new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude) , " ", string.Empty); trackingAnnotation.Content = coordonate.DateLocationCreation.FormatDateFromNow(); trackingAnnotation.IsInAlert = IsOutOf; PointsOfRoute.Add(trackingAnnotation); } else { var trackingAnnotation = new TrackingAnnotation(new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude) , " ", string.Empty); trackingAnnotation.Content = coordonate.DateLocationCreation.FormatDateFromNow(); trackingAnnotation.IsInAlert = IsOutOf; PointsOfRoute.Add(trackingAnnotation); } } } OnInitTrackingRouteComplete?.Invoke(null, null); }
private void SelectAnnotation() { MapViewControl.RemoveAnnotations(MapViewControl.Annotations); if (ViewModel.Annotation != null && ViewModel.Annotation.Addresses != null && ViewModel.Annotation.Addresses.Length > 0) { var annotations = ViewModel.Annotation.Addresses .Select(address => new MapViewAnnotation( ViewModel.Annotation.Pin, ViewModel.Annotation.Title, address)).ToArray(); var coordinates = MapUtil.GetAnnotationsCoordinates(annotations); MapViewControl.SetRegion( MapUtil.CoordinateRegionForCoordinates( coordinates, new MKMapSize(5000, 5000)), false); MapViewControl.AddAnnotations(annotations); MapViewControl.SelectAnnotation(annotations[0], false); } }