Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GMSMapView not showing anything

I currently have a UIView in my View Controller which I have changed to a GMSMapView in the Interface Builder, but nothing shows up, as shown in the picture below:

enter image description here

Here is the code that I am using

    let lat = 47.07903
    let long = -122.961283

    let camera = GMSCameraPosition.cameraWithLatitude(lat, longitude: long, zoom: 10)
    let map = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
    map.myLocationEnabled = true
    map.delegate = self
    self.mapView.addSubview(map)

    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2DMake(lat, long)
    marker.map = self.mapView

I have declared mapView as such using drag and drop:

@IBOutlet var mapView: GMSMapView!

Any help here would be much appreciated. I have tried a lot of different things! Thanks!

like image 673
Sampath Duddu Avatar asked Apr 01 '16 22:04

Sampath Duddu


1 Answers

This worked for me. https://stackoverflow.com/a/47308301/7560912 You probably have not enabled the google maps API. Go to your app-project's dashboard on https://console.developers.google.com and click the "ENABLE APIS AND SERVICES". There, under the MAPS section select "the Google maps sdk for ios" and enable it.

like image 52
HighAbove Avatar answered Oct 12 '22 14:10

HighAbove