@@ -14,6 +14,7 @@ class GMViewController: UIViewController {
1414 var cameraPosition : [ String : Double ] !
1515 var minimumClusterSize : Int ?
1616 var mapId : String ?
17+ var onViewDidLoad : ( ( ) -> Void ) ?
1718
1819 private var clusterManager : GMUClusterManager ?
1920
@@ -34,6 +35,7 @@ class GMViewController: UIViewController {
3435 }
3536
3637 self . view = GMapView
38+ self . onViewDidLoad ? ( )
3739 }
3840
3941 func initClusterManager( _ minClusterSize: Int ? ) {
@@ -94,10 +96,12 @@ public class Map {
9496 self . delegate = delegate
9597 self . mapViewController = GMViewController ( )
9698 self . mapViewController. mapId = config. mapId
97-
99+ self . mapViewController. onViewDidLoad = { [ weak self] in
100+ self ? . finishMapConfiguration ( )
101+ }
98102 self . render ( )
99103 }
100-
104+
101105 func render( ) {
102106 DispatchQueue . main. async {
103107 self . mapViewController. mapViewBounds = [
@@ -106,23 +110,28 @@ public class Map {
106110 " x " : self . config. x,
107111 " y " : self . config. y
108112 ]
109-
113+
110114 self . mapViewController. cameraPosition = [
111115 " latitude " : self . config. center. lat,
112116 " longitude " : self . config. center. lng,
113117 " zoom " : self . config. zoom
114118 ]
115-
119+
116120 self . targetViewController = self . getTargetContainer ( refWidth: self . config. width, refHeight: self . config. height)
117-
121+
118122 if let target = self . targetViewController {
119123 target. tag = Map . MAP_TAG
120124 target. removeAllSubview ( )
121125 self . mapViewController. view. frame = target. bounds
122126 target. addSubview ( self . mapViewController. view)
123- self . mapViewController. GMapView. delegate = self . delegate
124127 }
128+ }
129+ }
125130
131+ func finishMapConfiguration( ) {
132+ DispatchQueue . main. async {
133+ self . mapViewController. GMapView. delegate = self . delegate
134+
126135 if let styles = self . config. styles {
127136 do {
128137 self . mapViewController. GMapView. mapStyle = try GMSMapStyle ( jsonString: styles)
@@ -208,10 +217,11 @@ public class Map {
208217
209218 let height = Double ( ( item as? UIScrollView ) ? . contentSize. height ?? 0 )
210219 let width = Double ( ( item as? UIScrollView ) ? . contentSize. width ?? 0 )
211- let actualHeight = round ( height / 2 )
220+ let actualHeightFloor = floor ( height / 2 )
221+ let actualHeightCeil = ceil ( height / 2 )
212222
213- let isWidthEqual = width == self . config . width
214- let isHeightEqual = actualHeight == self . config . height
223+ let isWidthEqual = width == refWidth
224+ let isHeightEqual = actualHeightFloor == refHeight || actualHeightCeil == refHeight
215225
216226 if isWidthEqual && isHeightEqual && item. tag < self . targetViewController? . tag ?? Map . MAP_TAG {
217227 return item
0 commit comments