Google Maps SDKを使用してUIViewControllerでマップを生成していますが、画面全体にマップが生成されています。画面の半分にマップを作成する必要があります。私はそれをどのように達成するのですか?iOSで画面全体に適合しないGoogleマップを作成する
class MapViewController: UIViewController,CLLocationManagerDelegate{
var locationManager = CLLocationManager()
var mapView = GMSMapView()
override func viewDidLoad() {
super.viewDidLoad()
// User Location
locationManager.delegate = self
//locationManager.requestWhenInUseAuthorization()
locationManager.requestAlwaysAuthorization()
view.backgroundColor = UIColor.gray
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation = locations.last
let center = CLLocationCoordinate2D(latitude: userLocation!.coordinate.latitude, longitude: userLocation!.coordinate.longitude)
let camera = GMSCameraPosition.camera(withLatitude: userLocation!.coordinate.latitude,
longitude: userLocation!.coordinate.longitude, zoom: 9.1)
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.isMyLocationEnabled = true
self.view = mapView
locationManager.stopUpdatingLocation()
}
}