我想在Google地图上为代表们提供圈子,然后转换到segue中的另一个View Controller

问题描述 投票:1回答:1

问题

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

环境swift4适用于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)
    }

}
swift google-maps
1个回答
0
投票

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

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

这工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.