Ios 轻敲GMSPolygon Swift

Ios 轻敲GMSPolygon Swift,ios,swift,google-maps,tap,Ios,Swift,Google Maps,Tap,我的地图上有一些GMSPolygon: let españa = GMSMutablePath() españa.add(CLLocationCoordinate2D(latitude: 42.11, longitude: -9.37)) españa.add(CLLocationCoordinate2D(latitude: 43.94, longitude: -9.55)) españa.add(CLLocationCoordinate2D(latitude: 43.

我的地图上有一些GMSPolygon:

 let españa = GMSMutablePath()
    españa.add(CLLocationCoordinate2D(latitude: 42.11, longitude: -9.37))
    españa.add(CLLocationCoordinate2D(latitude: 43.94, longitude: -9.55))
    españa.add(CLLocationCoordinate2D(latitude: 43.60, longitude: -1.89))
    españa.add(CLLocationCoordinate2D(latitude: 42.02, longitude: 3.72))
    españa.add(CLLocationCoordinate2D(latitude: 36.16, longitude: -2.65))
    españa.add(CLLocationCoordinate2D(latitude: 37.10, longitude: -7.28))
    españa.add(CLLocationCoordinate2D(latitude: 42.08, longitude: -6.61))

我想点击它们来实现一些功能

我实现了这个方法:

import UIKit
import GoogleMaps



class ViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate {
}
当我点击它们时,什么也没发生

// ###### Click Country


private func myMapView(_ myMapView: GMSMapView, didTap overlay: GMSOverlay) {
    print("User Tapped Layer: \(overlay)")
}
我想我的
GMSMapViewDelegate
中有一个问题,但我无法修复它,我该怎么做

编辑:我已经有这个了

// ##### MAPA


    let mapCenter = GMSCameraPosition.camera(withLatitude: 48.23,
                                             longitude: 16.35,
                                             zoom: 3)

    myMapView.camera = mapCenter
    myMapView.setMinZoom(1, maxZoom: 8)

    myMapView.delegate = self


    // #### Estilo de mapa


    do {
        if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
            myMapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
        } else {
            NSLog("Unable to finde style.json")
        }
    } catch {
        NSLog("One or more of the map styles failed to load. \(error)")
    }

感谢

首先,感谢您使用我的问题答案:)

为什么将委托方法设置为私有的?我想这可能就是为什么没有人打电话给它的原因。拆下它。

最后它可以工作了

我的幻灯片菜单有问题:

RevealViewController
我不知道为什么使用RevealViewController,功能来自:

GSMapViewDelegate 
不起作用

现在,当我点击多边形时,我会在控制台中收到一个文本

但是我有关于多边形的全部信息,我需要它的名称

例如,如果我在西班牙点击,我想收到“你在西班牙点击”


谢谢你有这句话吗myMapView.delegate=self是的,我有。还有一个地图风格的工作性能。谢谢。我的回答有帮助吗?对不起,我不知道私人方法。如何删除它?非常感谢。只需使用退格从函数本身删除单词
private
。因此,您的函数应该是
func-myMapView(myMapView:GMSMapView,didTap-overlay:GMSOverlay)
而不是
private-func-myMapView(myMapView:GMSMapView,didTap-overlay:GMSOverlay)
我这样做了,但仍然没有工作。我还有定位功能,不工作单击Country func myMapView(myMapView:GMSMapView,didTap overlay:GMSOverlay){print(“用户点击的图层:(overlay)”)}//####在控制台中查找位置。func location(uMyMapView:GMSMapView,didTapAt坐标:CLLocationCoordinate2D){print(“您在(坐标.纬度)、(坐标.经度)”上点击过)}我不确定赋值运算符是如何工作的,但您能否尝试将
polygonEspaña.isTappable=true
移到上面
polygonEspaña.map=myMapView
仍然无法工作。我那样做了,什么也没发生。谢谢@emildavid
GSMapViewDelegate