Google Maps SDK for iOSを利用して地図上に円を描いて、その円をタップすると画面遷移するようにしたいと思い、公式のドキュメントを参考にして下のようなコードを書いたのですが、サークルをタップしても何も動きません。どこが間違っているのでしょうか?
######追加
何度もすみません
デリゲートの使い方
GMSMapViewDelegateのリファレンス
Google Maps SDK for iOS の使い方(Swift 4対応)
を参考にしてコードを書き換えましたがTappedCircleが呼ばれません。
######問題点
地図とサークルは表示されるのですが、タップしても反応しません
該当のソースコード
swift
1import UIKit 2import GoogleMaps 3import CoreLocation 4 5class ViewController: UIViewController, GMSMapViewDelegate{ 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 // Do any additional setup after loading the view, typically from a nib. 10 11 12 13 // map 14 let camera = GMSCameraPosition.camera(withLatitude: 35.687396, longitude: 139.743924, zoom: 17) 15 let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) 16 self.view = mapView 17 // mapView.isMyLocationEnabled 18 19 let circle = GMSCircle() 20 circle.position = CLLocationCoordinate2DMake(35.687396, 139.743924) 21 circle.radius = CLLocationDistance(10) 22 circle.fillColor = UIColor.blue 23 circle.isTappable = true 24 circle.map = mapView 25 func mapView(_ mapView: GMSMapView, didTapMarker: GMSCircle) -> Bool { 26 performSegue(withIdentifier: "goTalk", sender: nil) 27 return true 28 } 29 } 30 31 override func didReceiveMemoryWarning() { 32 super.didReceiveMemoryWarning() 33 // Dispose of any resources that can be recreated. 34 } 35 36 37 38 39 40}
###修正後のコード
swift
1import UIKit 2import GoogleMaps 3import CoreLocation 4 5class ViewController: UIViewController, GMSMapViewDelegate{ 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 // Do any additional setup after loading the view, typically from a nib. 10 11 12 13 // map 14 15 let camera = GMSCameraPosition.camera(withLatitude: 35.687396, longitude: 139.743924, zoom: 17) 16 let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) 17 mapView.delegate = self 18 self.view = mapView 19 // mapView.isMyLocationEnabled 20 21 let circle = GMSCircle() 22 circle.position = CLLocationCoordinate2DMake(35.687396, 139.743924) 23 circle.radius = CLLocationDistance(10) 24 circle.fillColor = UIColor.blue 25 // 26 circle.isTappable = true 27 circle.map = mapView 28 29 30 } 31 32 override func didReceiveMemoryWarning() { 33 super.didReceiveMemoryWarning() 34 // Dispose of any resources that can be recreated. 35 } 36 37 func TappedCircle(_ mapView: GMSMapView, didTapOverlay: GMSOverlay) -> Bool { 38 performSegue(withIdentifier: "goTalk", sender: nil) 39 return true 40 } 41 42 43 44}