Map is not shown but marker with given location is visible in swift

107 Views Asked by At

I am implementing GoogleMaps into my app, where I am adding API keys from GoogleConsole into delegate and showing location on map.

I am able to see location with Marker, but map is not seen, it shows white screen only.

Following is the code in AppDelegate.Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        GMSServices.provideAPIKey("AIzaSyDNSh77gQpIljcmEEFatjMivIjXXXXXXXX")
        GMSPlacesClient.provideAPIKey("AIzaSyDNSh77gQpIljcmEEFatjMivIjXXXXXXXX")
        return true
    }

And following is code to show map

viewDidLoad() {
        super.viewDidLoad()
        let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
        let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
        view = mapView
        
        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
        marker.title = "Sydney"
        marker.snippet = "Australia"
        marker.map = mapView
    }

Attaching screenshot how it's seen. Whats wrong I am doing here, why map is not visible. I have already added required keys and values into plist file as well.

Any help is appreciated. Thank you.

enter image description here

0

There are 0 best solutions below