StreetViewの表示

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 {
override func viewDidLoad() {
super.viewDidLoad()
let lat: CLLocationDegrees = 50.059139
let lon: CLLocationDegrees = -122.958391
let panoramaNear: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: lat,longitude: lon)
let panoView: GMSPanoramaView = GMSPanoramaView(frame: CGRect(x:0, y:0, width:self.view.bounds.width, height:self.view.bounds.height))
panoView.moveNearCoordinate(panoramaNear)
self.view.addSubview(panoView)
}
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 {
override func viewDidLoad() {
super.viewDidLoad()
let lat: CLLocationDegrees = 50.059139
let lon: CLLocationDegrees = -122.958391
let panoramaNear: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: lat,longitude: lon)
let panoView: GMSPanoramaView = GMSPanoramaView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
panoView.moveNearCoordinate(panoramaNear)
self.view.addSubview(panoView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
2.3と3.0の差分
- CGRectの初期化方法の変更(CGRectMakeの廃止)
Reference