Reputation: 21
First time coding and trying to use the Google Maps API.
My line of code is:
let mapView = GMSMapView.map(withFrame: view.frame, camera: camera)
The error I'm getting is:
map(withFrame: camera) is deprecated. use -init or -initWithOptions instead.
Everything I've tried either doesn't work or is also deprecated:
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)
Upvotes: 2
Views: 247
Reputation: 178
@IBOutlet weak var mapBaseView: UIView!
var mapView: GMSMapView?
func setMapView(){
let options = GMSMapViewOptions()
options.camera = GMSCameraPosition.camera(withLatitude:location.coordinate.latitude,
longitude: location.coordinate.longitude, zoom: currentZoomLevel)
options.frame = self.mapBaseView.bounds
mapView = GMSMapView(options: options
self.mapBaseView.addSubview(mapView ?? GMSMapView())
}
- Map View Declaration
- Options Initialisation
- Camera Setup
- Give frame
- add subview
Upvotes: 1
Reputation: 1
I faced this challenge before as well. This might help you:
let options = GMSMapViewOptions()
options.camera = camera
let mapView = GMSMapView.init(options: options)
enjoy :)
Upvotes: 0