void OnCameraPositionChanged(GCameraPosition pos) { if (Element == null) { return; } var mapModel = (Map)Element; var mkMapView = (MapView)Control; var region = mkMapView.Projection.VisibleRegion; var minLat = Math.Min(Math.Min(Math.Min(region.NearLeft.Latitude, region.NearRight.Latitude), region.FarLeft.Latitude), region.FarRight.Latitude); var minLon = Math.Min(Math.Min(Math.Min(region.NearLeft.Longitude, region.NearRight.Longitude), region.FarLeft.Longitude), region.FarRight.Longitude); var maxLat = Math.Max(Math.Max(Math.Max(region.NearLeft.Latitude, region.NearRight.Latitude), region.FarLeft.Latitude), region.FarRight.Latitude); var maxLon = Math.Max(Math.Max(Math.Max(region.NearLeft.Longitude, region.NearRight.Longitude), region.FarLeft.Longitude), region.FarRight.Longitude); #pragma warning disable 618 mapModel.VisibleRegion = new MapSpan(pos.Target.ToPosition(), maxLat - minLat, maxLon - minLon); #pragma warning restore 618 Map.Region = mkMapView.Projection.VisibleRegion.ToRegion(); var camera = pos.ToXamarinForms(); Map.CameraPosition = camera; Map.SendCameraChanged(camera); }
public static CameraPosition ToXamarinForms(this GCameraPosition self) { return(new CameraPosition( self.Target.ToPosition(), self.Bearing, self.ViewingAngle, self.Zoom )); }
void OnCameraPositionChanged(GCameraPosition pos) { if (Element == null) { return; } var mkMapView = (MapView)Control; Map.Region = mkMapView.Projection.VisibleRegion.ToRegion(); var camera = pos.ToXamarinForms(); Map.CameraPosition = camera; Map.SendCameraChanged(camera); }
void OnCameraPositionChanged(GCameraPosition pos) { if (Element == null) { return; } Device.BeginInvokeOnMainThread(() => { var mapModel = (Map)Element; var mkMapView = (MapView)Control; var region = mkMapView.Projection.VisibleRegion; var minLat = Math.Min(Math.Min(Math.Min(region.NearLeft.Latitude, region.NearRight.Latitude), region.FarLeft.Latitude), region.FarRight.Latitude); var minLon = Math.Min(Math.Min(Math.Min(region.NearLeft.Longitude, region.NearRight.Longitude), region.FarLeft.Longitude), region.FarRight.Longitude); var maxLat = Math.Max(Math.Max(Math.Max(region.NearLeft.Latitude, region.NearRight.Latitude), region.FarLeft.Latitude), region.FarRight.Latitude); var maxLon = Math.Max(Math.Max(Math.Max(region.NearLeft.Longitude, region.NearRight.Longitude), region.FarLeft.Longitude), region.FarRight.Longitude); mapModel.VisibleRegion = new MapSpan(pos.Target.ToPosition(), maxLat - minLat, maxLon - minLon); var camera = pos.ToXamarinForms(); Map.CameraPosition = camera; Map.SendCameraChanged(camera); }); }