@@ -9,7 +9,7 @@ import { Color } from "tns-core-modules/color";
99import * as imageSource from 'tns-core-modules/image-source' ;
1010import { Point } from "tns-core-modules/ui/core/view" ;
1111import { Image } from "tns-core-modules/ui/image" ;
12- import { GC } from "utils/utils"
12+ import { GC , layout } from "utils/utils"
1313
1414export * from "./map-view-common" ;
1515
@@ -202,17 +202,41 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
202202 if ( Number . isNaN ( height ) ) height = null ;
203203
204204 if ( ! height || ! width ) {
205- const bounds : CGRect = require ( "utils/utils" ) . ios . getter ( UIScreen , UIScreen . mainScreen ) . bounds ;
205+ const bounds : CGRect = UIScreen . mainScreen . bounds ;
206206 width = width || ( bounds . size . width * .7 ) ;
207207 height = height || ( bounds . size . height * .4 ) ;
208208 }
209209
210- require ( "ui/utils" ) . ios . _layoutRootView ( content , CGRectMake ( 0 , 0 , width , height ) )
210+ this . _layoutRootView ( content , CGRectMake ( 0 , 0 , width , height ) )
211211 return content . ios ;
212212 }
213213
214214 return null ;
215215 }
216+
217+ /*
218+ Replacement for _layoutRootView method removed in NativeScript 6
219+ */
220+ private _layoutRootView ( rootView , parentBounds ) {
221+ if ( ! rootView || ! parentBounds ) {
222+ return ;
223+ }
224+
225+ const size = parentBounds . size ;
226+ const width = layout . toDevicePixels ( size . width ) ;
227+ const height = layout . toDevicePixels ( size . height ) ;
228+
229+ const widthSpec = layout . makeMeasureSpec ( width , layout . EXACTLY ) ;
230+ const heightSpec = layout . makeMeasureSpec ( height , layout . EXACTLY ) ;
231+
232+ rootView . measure ( widthSpec , heightSpec ) ;
233+
234+ const origin = parentBounds . origin ;
235+ const left = origin . x ;
236+ const top = origin . y ;
237+
238+ rootView . layout ( left , top , width , height ) ;
239+ }
216240}
217241
218242
0 commit comments