I want to display google maps on a view that\'s then added to self.view, rather than drawing the map directly on self.view. Therefore, I created a
Those answers didn't work for me as I wanted. As an improvement for @Rajan's answer, I thought of adding an UIView to storyboard View Controller with desired constraints. Then I added another UIView inside that as child and then I changed class name to GMSMapView. After that I made an Outlet to UIViewController.
@IBOutlet weak var GMSMap: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
let mapView = GMSMapView.map(withFrame: GMSMap.frame, camera: GMSCameraPosition.camera(withLatitude: 6.9271, longitude: 79.8612, zoom: 10))
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 6.9271, longitude: 79.8612)
marker.title = "Colombo"
marker.snippet = "Sri Lanka"
marker.map = mapView
self.view.addSubview(mapView)
}