public void CenterOnZone() { if (ZonePolygon != null && ZonePolygon.Points != null) { MapViewControl.SetVisibleMapRect(ZonePolygon.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true); } }
public void CenterOnLocations(List <LatitudeLongitude> locations , bool with_animation = false) { if (locations == null || locations.Count == 0) { return; } var minLat = locations.Select(el => el.Latitude).Min(); var minLong = locations.Select(el => el.Longitude).Min(); var maxLat = locations.Select(el => el.Latitude).Max(); var maxLong = locations.Select(el => el.Longitude).Max(); var coordinateMin = new CLLocationCoordinate2D(minLat, minLong); var coordinateMax = new CLLocationCoordinate2D(maxLat, maxLong); var upperLeft = MKMapPoint.FromCoordinate(coordinateMin); var lowerRight = MKMapPoint.FromCoordinate(coordinateMax); var mapRect = new MKMapRect(upperLeft.X , upperLeft.Y , lowerRight.X - upperLeft.X , lowerRight.Y - upperLeft.Y); var region = MKCoordinateRegion.FromMapRect(mapRect); MapViewControl.SetVisibleMapRect(mapRect , new UIEdgeInsets(50, 20, 100, 20) , true); try { if (region.Center.Latitude > -89 && region.Center.Latitude < 89 && region.Center.Longitude > -179 && region.Center.Longitude < 179) { if (region.Span.LatitudeDelta < 0) { region.Span.LatitudeDelta = 0.0; } if (region.Span.LongitudeDelta < 0) { region.Span.LongitudeDelta = 0.0; } MapViewControl.SetRegion(region, with_animation); } } catch (Exception) { //UIAlertView alert = new UIAlertView("Exception", String.Format("{0} \n {1}?", e.Message, e.StackTrace), null, "Cancel"); //alert.Show(); } }
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 CreateRouteForeground(List <LocationDTO> coordonates) { if (PointsOfRoute != null && PointsOfRoute.Count != 0) { foreach (var annotation in PointsOfRoute) { MapViewControl.AddAnnotation(annotation); } var positionWithSeekios = PointsOfRoute.Select(s => s.Coordinate).ToList(); if (SelectedAnnotation != null && !positionWithSeekios.Contains(SelectedAnnotation.Coordinate)) { positionWithSeekios.Add(SelectedAnnotation.Coordinate); } var polygon = MKPolyline.FromCoordinates(positionWithSeekios.ToArray()); MapViewControl.AddOverlay(polygon); MapViewControl.SetVisibleMapRect(polygon.BoundingMapRect, new UIEdgeInsets(50, 40, 100, 40), true); } }
public MKCircle CreateAccuracyArea(double latitude , double longitude , double accuracy) { if (_accuracyArea != null) { MapViewControl.RemoveOverlay(_accuracyArea); } if (accuracy <= 0) { return(null); } var centerPostion = new CLLocationCoordinate2D(latitude, longitude); var circle = MKCircle.Circle(centerPostion, accuracy); MapViewControl.AddOverlay(circle); MapViewControl.SetVisibleMapRect(circle.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true); _accuracyArea = circle; return(_accuracyArea); }