以下是一些代码: mainMapController
@IBOutlet weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude: 38.96351774, longitude:-77.01957901, zoom: 15.0)
mapVIEW.camera = camera <-------- it errors on this line.
}
verifyCodeController:
if code == codeField.text{
numberInUse(number: phoneNumber!, completionHandler: { (Value) in
if Value == true{
print("toMap segue")
print(Value)
self.performSegue(withIdentifier: "nextMap", sender: nil)
}
答案 0 :(得分:2)
Documentation显示了如何初始化地图
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
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 mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
更新:
确保在App Startup上设置API密钥:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("YOUR_API_KEY")
return true
}