public void CreateSeekiosMarkerAsync(string seekiosId , string title , string imageBase64 , DateTime?lastLocationDate , double latitude , double longitude , double accuracy , bool isDontMove = false , bool isInAlert = false) { var seekiosLocation = new CLLocationCoordinate2D(latitude, longitude); var seekiosImg = CreateSeekiosBitmap(imageBase64, accuracy, isInAlert, isDontMove); var seekiosAnnotation = new SeekiosAnnotation(seekiosLocation, seekiosImg); seekiosAnnotation.IdSeekios = int.Parse(seekiosId); MapViewControl.AddAnnotations(seekiosAnnotation); SelectedAnnotation = seekiosAnnotation; CreateAccuracyArea(latitude, longitude, accuracy); seekiosAnnotation.IsAlert = isInAlert; _annotations.Add(seekiosAnnotation); _annotationIdAssociation.Add(new SeekiosMarkerIdAssociation(seekiosId, seekiosAnnotation.Id)); if (App.Locator.ModeZone.IsOnEditMode && App.Locator.ModeZone.IsActivityFocused) { } else { MapViewControl.SelectAnnotation(seekiosAnnotation, true); } }
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 bool CenterInMarker(string seekiosId , bool showAnnotation = false , bool withAnimation = false) { var idAnnotationAsso = _annotationIdAssociation.FirstOrDefault(id => id.SeekiosId == seekiosId); if (idAnnotationAsso == null) { return(false); } var seekiosAnnotation = _annotations.FirstOrDefault(annotation => annotation.Id.Equals(idAnnotationAsso.MarkerId)); if (seekiosAnnotation == null) { return(false); } var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.Idseekios.ToString() == seekiosId); if (seekios != null) { if (seekios.LastKnownLocation_accuracy > 0) { var centerPostion = new CLLocationCoordinate2D(seekios.LastKnownLocation_latitude , seekios.LastKnownLocation_longitude); var circle = MKCircle.Circle(centerPostion , seekios.LastKnownLocation_accuracy); MapViewControl.SetVisibleMapRect(circle.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true); } else { CenterInLocalisation(seekios.LastKnownLocation_latitude , seekios.LastKnownLocation_longitude , (float)ZoomLevelEnum.BigZoom , withAnimation); } } if (showAnnotation) { SelectedAnnotation = seekiosAnnotation; MapViewControl.SelectAnnotation(seekiosAnnotation, withAnimation); } return(true); }
public void ChangeAnnotationLocation(string seekiosId , double latitude , double longitude , double accuracy) { var idMarkerAsso = _annotationIdAssociation.FirstOrDefault(id => id.SeekiosId == seekiosId); if (idMarkerAsso != null) { var annotation = _annotations.FirstOrDefault(m => m.Id.Equals(idMarkerAsso.MarkerId)); if (annotation != null) { var mapCenter = new CLLocationCoordinate2D(latitude, longitude); annotation.SetCoordinate(mapCenter); MapViewControl.SelectAnnotation(annotation, true); MapViewControl.SetCenterCoordinate(mapCenter, true); } } }
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); } }