@@ -55,7 +55,7 @@ public void Initialize()
5555 // Unfortunately the SKGLView does not have a IgnorePixelScaling property. We have to adjust for density with SKGLView.Scale.
5656 _density = PixelsPerDeviceIndependentUnit ;
5757
58- TryInitializeViewport ( _canvas . Frame . Width , _canvas . Frame . Height ) ;
58+ TryInitializeViewport ( ScreenWidth , ScreenHeight ) ;
5959
6060 ClipsToBounds = true ;
6161 MultipleTouchEnabled = true ;
@@ -99,7 +99,7 @@ private void OnSingleTapped(UITapGestureRecognizer gesture)
9999
100100 void OnPaintSurface ( object sender , SKPaintGLSurfaceEventArgs args )
101101 {
102- TryInitializeViewport ( _canvas . Frame . Width , _canvas . Frame . Height ) ;
102+ TryInitializeViewport ( ScreenWidth , ScreenHeight ) ;
103103 if ( ! _map . Viewport . Initialized ) return ;
104104
105105 args . Surface . Canvas . Scale ( _density , _density ) ; // we can only set the scale in the render loop
@@ -217,8 +217,8 @@ public override CGRect Frame
217217
218218 if ( _map ? . Viewport == null ) return ;
219219
220- _map . Viewport . Width = _canvas . Frame . Width ;
221- _map . Viewport . Height = _canvas . Frame . Height ;
220+ _map . Viewport . Width = ScreenWidth ;
221+ _map . Viewport . Height = ScreenHeight ;
222222
223223 Refresh ( ) ;
224224 }
@@ -232,8 +232,8 @@ public override void LayoutMarginsDidChange()
232232
233233 if ( _map ? . Viewport == null ) return ;
234234
235- _map . Viewport . Width = _canvas . Frame . Width ;
236- _map . Viewport . Height = _canvas . Frame . Height ;
235+ _map . Viewport . Width = ScreenWidth ;
236+ _map . Viewport . Height = ScreenHeight ;
237237
238238 Refresh ( ) ;
239239 }
@@ -283,5 +283,8 @@ private static (Point centre, double radius, double angle) GetPinchValues(List<P
283283
284284 return ( new Point ( centerX , centerY ) , radius , angle ) ;
285285 }
286+
287+ public float ScreenWidth => ( float ) _canvas . Frame . Width ; // todo: check if we need _canvas
288+ public float ScreenHeight => ( float ) _canvas . Frame . Height ; // todo: check if we need _canvas
286289 }
287290}
0 commit comments