如何在iOS app + Swift中控制googlemap的大小?

Abd*_*lah 1 iphone google-maps ios google-maps-sdk-ios swift

我正在尝试构建一个使用googleMaps API的iOS应用.到目前为止,我做了很多工作,但我遇到了一个问题,即"我无法控制应用程序中显示的地图大小".它总是需要全屏.显然,我错过了一些东西.

这是我的代码的快照:

        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestAlwaysAuthorization()
        locationManager.startUpdatingLocation()
        locationManager.delegate =  self

        /// Google maps stuff
        let camera = GMSCameraPosition.camera(withLatitude:-33.8688,longitude: 151.2093, zoom: 13.0)
        self.mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
        self.mapView.isMyLocationEnabled = true
        /// Google maps stuff
Run Code Online (Sandbox Code Playgroud)

大多数解决方案是关于添加UIView(UIView = myView)然后使用此视图,如:

self.myView = mapView 
Run Code Online (Sandbox Code Playgroud)

要么

self.myView = self.mapView 
Run Code Online (Sandbox Code Playgroud)

他们没跟我合作:(

Div*_*iya 5

let camera = GMSCameraPosition.camera(withLatitude: coordinates.latitude,longitude:coordinates.longitude, zoom:15)
let mapView = GMSMapView.map(withFrame: CGRect(x: 0, y: 64, width: self.view.frame.size.width, height: self.view.frame.size.height), camera: camera)
DispatchQueue.main.async(execute: {
    mapView.animate(toLocation: coordinates)
    UIView.animate(withDuration: 0.4, animations: {
        mapView.layoutIfNeeded()
    })
})

mapView.isMyLocationEnabled = true
let marker = GMSMarker()
marker.position = camera.target
mapView.isUserInteractionEnabled = true
marker.title = "\(self.strLabelHeading)!"
marker.map = mapView
self.viewMap.addSubview(mapView)
Run Code Online (Sandbox Code Playgroud)