第一次编码并尝试使用 Google Maps API。
我的代码行是:
let mapView = GMSMapView.map(withFrame: view.frame, camera: camera)
我收到的错误是:
map(withFrame:camera) 已弃用。请使用 -init 或 -initWithOptions 代替。
我尝试过的所有方法要么不起作用,要么已被弃用:
let mapView = GMSMapView(frame: self.view.bounds, camera: camera)
let mapView = GMSMapView.map(withFrame: view.frame, camera: camera)
let mapView = GMSMapView(frame: view.bounds, camera: camera)
let mapView = GMSMapView(view.frame, camera:camera)
let mapView = GMSMapView(frame: view.bounds)
我以前也面临过这个挑战。这可能对你有帮助:
let options = GMSMapViewOptions()
options.camera = camera
let mapView = GMSMapView.init(options: options)
享受:)