Reputation: 655
I just upgraded to Xcode 7.1. When I try to set the mapType of a GMSMapView I get the error Ambiguous use of 'kGMSTypeNormal', Ambiguous use of 'kGMSTypeTerrain', and Ambiguous use of 'kGMSTypeHybrid'.
@IBOutlet weak var mapView: GMSMapView!
func myfunc() {
if let myMapType = NSUserDefaults.standardUserDefaults().stringForKey(SettingsTableViewController.History.MapType) {
switch myMapType {
case "kGMSTypeNormal":
mapView.mapType = kGMSTypeNormal
case "kGMSTypeTerrain":
mapView.mapType = kGMSTypeTerrain
case "kGMSTypeHybrid":
mapView.mapType = kGMSTypeHybrid
default: break
mapView.mapType = kGMSTypeNormal
}
} else {
mapView.mapType = kGMSTypeNormal
}
}
Upvotes: 7
Views: 2482
Reputation: 19
here is the updated version
import UIKit
import GoogleMaps
class ViewController: UIViewController, GMSMapViewDelegate {
var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
mapView = GMSMapView(frame: self.view.bounds)
mapView.animate(toViewingAngle: 45)
mapView.mapType = GMSMapViewType.satellite
self.view = mapView
}
Upvotes: 2
Reputation: 2273
mapView.mapType = GMSMapViewType(rawValue: 1)!
Upvotes: 2
Reputation: 11
You need to use like this
mapView.mapType = GoogleMaps.kGMSTypeSatellite
Upvotes: 0
Reputation: 655
I'm not sure why but putting "GoogleMaps." in front of all the kGMSTypes (i.e. GoogleMaps.kGMSTypeNormal) fixed the problem.
Upvotes: 12
Reputation: 2187
If you open GMSMapViewType, you will see it defined as enum. In your switch statement, you're comparing it with strings which is wrong. You should better compare them with integers.
kGMSTypeNormal = 1
kGMSTypeSatellite = 2
kGMSTypeTerrain = 3
kGMSTypeHybrid = 4
kGMSTypeNone = 5
Upvotes: 0