public void RemoveSelectedHistoryMarker() { if (SelectedLocationHistory == null) { return; } MapViewControl.RemoveAnnotation(SelectedLocationHistory); }
public void ChangeSelectedLocationHistory(LocationDTO coordonate) { // remove the old position if its exist if (SelectedLocationHistory != null) { MapViewControl.RemoveAnnotation(SelectedLocationHistory); } // if we don't need to select, exit if (coordonate == null) { return; } // remplacing with the new annotation var location = new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude); SelectedLocationHistory = new HistoricAnnotation(location , " " , string.Empty); ((HistoricAnnotation)SelectedLocationHistory).Content = coordonate.DateLocationCreation.FormatDateFromNow(); MapViewControl.AddAnnotation(SelectedLocationHistory); // display accuracy if necessary CreateAccuracyArea(coordonate.Latitude , coordonate.Longitude , coordonate.Accuracy); //// center the new annotation on the map //if (!App.Locator.ModeZone.IsOnEditMode) //{ // if (coordonate.Accuracy == 0) // { // CenterInLocalisation(coordonate.Latitude // , coordonate.Longitude // , 0 // , true); // } // else // { // CenterInLocalisation(coordonate.Latitude // , coordonate.Longitude // , 0 // , true); // //// display the annotation with accurency and focus on the circle // //_mapViewControl.MapRectThatFits(CreateAccuracyArea(coordonate.Latitude // //, coordonate.Longitude // //, coordonate.Accuracy).BoundingMapRect); // } //} // display the annotation view MapViewControl.SelectAnnotation(SelectedLocationHistory, true); //CreateAccuracyArea(coordonate.Latitude // , coordonate.Longitude // , coordonate.Accuracy); }
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 AddPointToZone() { //if (_recognizer.State == UIGestureRecognizerState.Began) //{ // _dragStarted = false; // Console.WriteLine("Began !"); // return; //} //else if (_recognizer.State == UIGestureRecognizerState.Changed) //{ // _dragStarted = true; // Console.WriteLine("Drag !"); // // Do dragging stuff here //} //else if (_recognizer.State == UIGestureRecognizerState.Ended){ // if (_dragStarted) // { // Console.WriteLine("Ended 1!"); // _dragStarted = false; // return; // } // else { // Console.WriteLine("Ended !"); // } // } if (_recognizer.State == UIGestureRecognizerState.Began) { //if (_recognizer.State == UIGestureRecognizerState.Began || !IsOnPointAdding) return; if (ZonePolygon != null && ZonePolygon.Points.Count() > App.Locator.ModeZone.MAX_NUMBER_OF_POINTS) { return; } // convert touched position to map coordinate var userTouch = _recognizer.LocationInView(MapViewControl); var mapPoint = MapViewControl.ConvertPoint(userTouch, MapViewControl); var newAnnotation = new ModeZoneAnnotation(mapPoint, true); // change the previous annotation to green var lastAnnotation = PointsOfZone.LastOrDefault(); if (lastAnnotation != null) { MapViewControl.RemoveAnnotation(lastAnnotation); ((ModeZoneAnnotation)lastAnnotation).IsLastAnnotation = false; MapViewControl.AddAnnotation(lastAnnotation); } // refresh the polygone List <LatitudeLongitude> zone = PointsOfZone.Select(el => new LatitudeLongitude(el.Coordinate.Latitude, el.Coordinate.Longitude)).ToList(); zone.Add(new LatitudeLongitude(mapPoint.Latitude, mapPoint.Longitude)); if (!App.Locator.ModeZone.CheckCorrectAreaFormat(zone)) { return; } var pointsToRestore = PointsOfZone.Select(el => el.Coordinate).ToList(); PointsOfZone.Add(newAnnotation); MapViewControl.AddAnnotation(newAnnotation); var isInAlert = MapViewModelBase.Mode != null && MapViewModelBase.Mode.StatusDefinition_idstatusDefinition != 1; CreateZone(PointsOfZone.Select(s => new LatitudeLongitude(s.Coordinate.Latitude, s.Coordinate.Longitude)).ToList(), isInAlert, true, 0); RefreshZone(); // reverse the action UndoActions.Add(new Action(() => { MapViewControl.RemoveAnnotation(newAnnotation); PointsOfZone.Remove(PointsOfZone.Last()); var lastAnnotationUndo = PointsOfZone.LastOrDefault(); if (lastAnnotationUndo != null) { MapViewControl.RemoveAnnotation(lastAnnotationUndo); ((ModeZoneAnnotation)lastAnnotationUndo).IsLastAnnotation = true; MapViewControl.AddAnnotation(lastAnnotationUndo); } CreateZone(pointsToRestore.Select(s => new LatitudeLongitude(s.Latitude, s.Longitude)).ToList(), isInAlert, true, 0); RefreshZone(); if (ZonePolygon == null || ZonePolygon.Points == null || PointsOfZone.Count() < 3) { _nextButton.Enabled = false; } else { _nextButton.Enabled = true; } })); // if the zone contain 3 points, enable the next button if (PointsOfZone.Count < 3) { _nextButton.Enabled = false; } else { _nextButton.Enabled = true; } } }