Reputation: 207
I'm trying to add GMS Mapview from the google maps api into my app. When I followed a tutorial for how to implement it, Xcode cant seem to understand that GMSMapview is an UIView.
This is my code
import SwiftUI
import GoogleMaps
struct MapsView: UIViewRepresentable {
private let zoomLevel: Float = 10.0
@ObservedObject var locationManager = LocationService()
func makeUIView(context: Context) -> some GMSMapView {
let camera = GMSCameraPosition.camera(withLatitude: locationManager.lat, longitude: locationManager.lat, zoom: zoomLevel)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
return mapView
}
func updateUIView(_ mapView: GMSMapView, context: Context) {
mapView.animate(toLocation: CLLocationCoordinate2D(latitude: locationManager.lat, longitude: locationManager.lon))
}
}
Xcode does not show any type of solutions for me to make it conform either.
In my Podfile I have only added "GoogleMaps" without version num. So I believe I am using the newest version.
Is this a known bug in the Google Maps package or am I doing something wrong?
Upvotes: 1
Views: 583
Reputation: 18914
Remove some
word.
func makeUIView(context: Context) -> GMSMapView { //<-- here
let camera = GMSCameraPosition.camera(withLatitude: locationManager.lat, longitude: locationManager.lat, zoom: zoomLevel)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
return mapView
}
Upvotes: 2