我想让代表参加GoogleMap上的圈子,并在过渡中过渡到另一个ViewController

时间:2019-03-13 14:12:19

标签: swift google-maps

问题

当我点击使用GMSCircle绘制的圆圈而不是标记或标题时,我想进行屏幕转换。 我在下面编写了代码,但是点击圆圈不会在调试区域显示任何内容,因此我无法进行过渡。 缺少什么?

环境 迅捷4 适用于iOS的Google Maps SDK Xcode 9.4.1

import UIKit
import GoogleMaps
import CoreLocation

class ViewController: UIViewController, GMSMapViewDelegate{

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        // map
        let camera = GMSCameraPosition.camera(withLatitude: 35.687396, longitude: 139.743924, zoom: 17)
        let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
        mapView.delegate = self
        self.view = mapView
        // mapView.isMyLocationEnabled

        let circle = GMSCircle()
        circle.position = CLLocationCoordinate2DMake(35.687396, 139.743924)
        circle.radius = CLLocationDistance(10)
        circle.fillColor = UIColor.blue
        circle.isTappable = true
        circle.map = mapView
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    func mapView(_ mapView: GMSMapView, didTapCircle: GMSCircle) {
        performSegue(withIdentifier: "goTalk", sender: nil)
    }

}

1 个答案:

答案 0 :(得分:0)

我检查了发生了什么,我注意到如您所说,它没有用。 But according to this answer,我注意到您还需要其他委托方法:

    func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
        performSegue(withIdentifier: "goTalk", sender: nil)
    }

这正常工作。