Заменить
var mainView:UIView = GMSMapView.init(frame: CGRect(x:50,y:150,width:250,height:300))
self.view.addSubview(mainView)
let mapView = GMSMapView.map(withFrame: mainView.frame, camera: camera)
mainView = mapView
с
var mainView:GMSMapView! // instance var
// in viewDidLoad
let camera = GMSCameraPosition.camera(withLatitude: 51.5, longitude: -0.127, zoom: 12.0)
mainView = GMSMapView.map(withFrame:CGRect(x:50,y:150,width:250,height:300), camera: camera)
mapView.delegate = self
self.view.addSubview(mainView)