map(withFrame:camera) 已弃用?我该如何解决这个问题?

问题描述 投票:0回答:1

第一次编码并尝试使用 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)
    
    
gmsmapview
1个回答
0
投票

我以前也面临过这个挑战。这可能对你有帮助:

let options = GMSMapViewOptions()
options.camera = camera
    
let mapView = GMSMapView.init(options: options)

享受:)

© www.soinside.com 2019 - 2024. All rights reserved.