GoogleMapを表示する

Swift3.0
AppDelegate.swift
import UIKit
import GoogleMaps
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
GMSServices.provideAPIKey("取得したAPIKey")
return true
}
}
ViewController.swift
import UIKit
import GoogleMaps
class ViewController: UIViewController, GMSMapViewDelegate {
var gmaps : GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
gmaps = GMSMapView(frame: CGRect(x:0, y:0, width:self.view.bounds.width, height:self.view.bounds.height))
self.view.addSubview(gmaps)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Swift 2.3
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
GMSServices.provideAPIKey("取得したAPIKey")
return true
}
}
ViewController.swift
import UIKit
class ViewController: UIViewController, GMSMapViewDelegate {
var gmaps : GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
gmaps = GMSMapView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
self.view.addSubview(gmaps)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
2.3と3.0の差分
- CGRectの初期化方法の変更(CGRectMakeの廃止)
Reference