Как сделать мой GMSPolygon доступным в Swift с помощью Google Maps API

Google Maps API работает, все бинарные библиотеки связаны, -Obj в целевом «другом флаге компоновщика» включен и создан заголовочный файл objc, и этот код в основном взят прямо из демонстрации разработчиков Google о том, как добавить прослушивание событий. Тем не менее, по какой-то причине - хотя моя карта, полигон и маркер работают - я не могу понять, как сделать мой единственный полигон доступным для нажатия. (В конце концов я хочу изменить цвет с красного на зеленый и обратно при нажатии пользователем). Я новичок в Swift и Xcode, использую последние обновления, и мне действительно может понадобиться помощь!

Вот мой код:

class ViewController: UIViewController, GMSMapViewDelegate {

override func loadView() {
    let camera = GMSCameraPosition.camera(withLatitude: 40.0, longitude: -75.3, zoom: 17.0)
    let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
    mapView.delegate = self
    self.view = mapView

    // Creates a marker in the center of the map.
    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2D(latitude: 40.0, longitude: -75.3)
    marker.title = "University1"
    marker.isTappable = true
    marker.map = mapView

    // Create a rectangular path
    let K1 = GMSMutablePath()
    K1.add(CLLocationCoordinate2D(latitude: 40.04080470744396, longitude: -75.34219389549136))
    K1.add(CLLocationCoordinate2D(latitude: 40.04082335573317, longitude: -75.34220634745961))
    K1.add(CLLocationCoordinate2D(latitude: 40.0407983689258, longitude: -75.34226262271473))
    K1.add(CLLocationCoordinate2D(latitude: 40.04078009018794, longitude: -75.34224985832812))
    let K1polygon = GMSPolygon(path: K1)
    K1polygon.fillColor = UIColor(red: 0.25, green: 0, blue: 0, alpha: 0.05);
    K1polygon.strokeColor = .red
    K1polygon.strokeWidth = 2
    K1polygon.isTappable = true
    K1polygon.map = mapView

}}
func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
print("You did it!")
}

let geocoder = GMSGeocoder()

func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
mapView.clear()
}

func mapView(_ mapView: GMSMapView, idleAt cameraPosition: GMSCameraPosition)    {
geocoder.reverseGeocodeCoordinate(cameraPosition.target) { (response, error)    in
    guard error == nil else {
        return
    }

    if let result = response?.firstResult() {
        let marker = GMSMarker()
        marker.position = cameraPosition.target
        marker.title = result.lines?[0]
        marker.snippet = result.lines?[1]
        marker.map = mapView
    }
}}

person swift_student    schedule 26.04.2017    source источник
comment
stackoverflow.com/questions/39977363/   -  person GIJOW    schedule 26.04.2017