private void PositionMap() { if (ItemsSource == null || !ItemsSource.Any()) { return; } var centerPosition = new Position(ItemsSource.Average(x => x.Latitude), ItemsSource.Average(x => x.Longitude)); var minLongitude = ItemsSource.Min(x => x.Longitude); var minLatitude = ItemsSource.Min(x => x.Latitude); var maxLongitude = ItemsSource.Max(x => x.Longitude); var maxLatitude = ItemsSource.Max(x => x.Latitude); var distance = MapHelper.CalculateDistance(minLatitude, minLongitude, maxLatitude, maxLongitude, 'M') / 2; AssociatedObject.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance))); Device.StartTimer(TimeSpan.FromMilliseconds(500), () => { AssociatedObject.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance))); return(false); }); }
private void PositionMap() { if (ItemsSource == null || !ItemsSource.Any()) { return; } var centerPosition = new Position(ItemsSource.Average(x => x.Latitude), ItemsSource.Average(x => x.Longitude)); var distance = 0.5; _map.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance))); Device.StartTimer(TimeSpan.FromMilliseconds(500), () => { _map.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance))); return(false); }); }