I have some GMSPolygon in my map:
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))
let polygonEspaña = GMSPolygon(path: españa)
polygonEspaña.fillColor = UIColor(red : 0, green: 0, blue: 0, alpha: 0.05);
polygonEspaña.strokeColor = .black
polygonEspaña.strokeWidth = 2
polygonEspaña.map = myMapView
polygonEspaña.isTappable = true
I want tap them to make some functions.
I implemented this method:
import UIKit
import GoogleMaps
class ViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate {
}
When I tap them nothing happen.
// ###### Click Country
private func myMapView(_ myMapView: GMSMapView, didTap overlay: GMSOverlay) {
print("User Tapped Layer: \(overlay)")
}
I think that i have a issue in my GMSMapViewDelegate
but i can´t fix it, how could i do that?
EDIT: I Already have this also.
// ##### 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)")
}
Thanks