rome 웃
rome 웃

Reputation: 1901

Show GoogleMaps on View in Swift?

My code:

var camera = GMSCameraPosition.cameraWithLatitude(currentLocation.latitude, longitude: currentLocation.longitude, zoom: 12) 
//latitude, longitude like :31.230416 and 121.473701.
let map = GMSMapView(frame: CGRectZero)
map.delegate = self
map.camera = camera
self.view = map

It work fine! like this:

enter image description here

But when I create new View: @IBOutlet weak var mapView: UIView!

Then change this line: self.view = map to self.mapView = map

It not work for me, I get a blank view.

Upvotes: 6

Views: 2922

Answers (1)

rome 웃
rome 웃

Reputation: 1901

I fixed it by go to my view (view display map), then change class my view to GMSMapView. enter image description here

Upvotes: 11

Related Questions