GMSMapView does not show anything

I currently have a UIView in my View Controller, which I changed to GMSMapView in Interface Builder, but nothing is displayed, as shown in the image below:

enter image description here

Here is the code I'm 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 declared mapViewas such using drag and drop:

@IBOutlet var mapView: GMSMapView!

Any help here would be much appreciated. I tried many different things! Thank!

+6
source share
5 answers

. fooobar.com/questions/561612/... , API Google. - https://console.developers.google.com "ENABLE APIS AND SERVICES". , MAPS, "Google maps sdk ios" .

+4

, API Google Dev Console, .

AppDelegate.m application:didFinishLaunchingWithOptions: :

[GMSServices provideAPIKey:@"YOUR_API_KEY"];

. 4 5

+3

, , - .

1) , ios Google Map.

2) Google.

3) ios google services .

GMSPlacesClient.provideAPIKey("API-KEY")
GMSServices.provideAPIKey("API-KEY")

4) , .

, , .

+2

mapview , GMSCameraPostion. markers - > https://developers.google.com/maps/documentation/ios-sdk/marker#change_the_marker_opacity

let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(lat, long)
marker.map = self.mapView
mapView.camera = GMSCameraPosition.cameraWithTarget(marker.position, zoom: 13)
0

"ENABLE APIS AND SERVICES". enter image description here

work for me, you can try this.

0
source

All Articles