Mahin Ibrahim Mahin Ibrahim - 2 months ago 36
Swift Question

AutoLayout in GMSMapView

I need GMSMapView in a particular view. Here viewForGMSMapView is my UIView. I used the below code.

let camera = GMSCameraPosition.cameraWithLatitude(-33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.mapWithFrame(viewForGMSMapView.bounds, camera: camera)

mapView.translatesAutoresizingMaskIntoConstraints = true;

mapView.myLocationEnabled = true

It helps to fix in my view. But when device screensize increases it fails. How to autolayout this GMSMapView. I need it to fit in my View


If you want translatesAutoresizingMaskIntoConstraints to be true, you need to set an appropriate autoresizingMask so it resizes or shrinks correctly.


mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

Otherwise, you need to set translatesAutoresizingMaskIntoConstraints to false and set up constraints for the map view.