I am using GMSMapview to display the polyline. If I use self.view it's worked perfect.
let camera = GMSCameraPosition.camera(withLatitude: 0, longitude:-165, zoom:2)
let mapView = GMSMapView.map(withFrame: self.gMap.bounds, camera:camera)
let path = GMSMutablePath()
path.addLatitude(-33.866, longitude:151.195) // Sydney
path.addLatitude(-18.142, longitude:178.431) // Fiji
path.addLatitude(21.291, longitude:-157.821) // Hawaii
path.addLatitude(37.423, longitude:-122.091) // Mountain View
let polyline = GMSPolyline(path: path)
polyline.strokeColor = UIColor.blue
polyline.strokeWidth = 5.0
polyline.map = mapView
self.gMap.isHidden = true
self.view = mapView
But while I used GMSMapView as subview to display the polyline it's not getting updated.
@IBOutlet weak var gMap: GMSMapView!
let camera = GMSCameraPosition.camera(withLatitude: 0, longitude:-165, zoom:2)
let mapView = GMSMapView.map(withFrame: self.gMap.bounds, camera:camera)
let path = GMSMutablePath()
path.addLatitude(-33.866, longitude:151.195) // Sydney
path.addLatitude(-18.142, longitude:178.431) // Fiji
path.addLatitude(21.291, longitude:-157.821) // Hawaii
path.addLatitude(37.423, longitude:-122.091) // Mountain View
let polyline = GMSPolyline(path: path)
polyline.strokeColor = UIColor.blue
polyline.strokeWidth = 5.0
polyline.map = mapView
//self.gMap.isHidden = true
self.gMap = mapView