click on GMSPolygon swift with Googlemaps

0

I have a GMSPolygon visible on the Googlemaps map. I want to click (tap) and have the console send me a message.

 // ##### Polígonos


    let polygonEspaña = GMSPolygon(path: españa)
    polygonEspaña.fillColor = UIColor(red : 0.25, green: 0, blue: 0, alpha: 0.05);
    polygonEspaña.strokeColor = .black
    polygonEspaña.strokeWidth = 2
    polygonEspaña.map = myMapView
    polygonEspaña.isTappable = true


}

 //  END VIEW DID LOAD




// ###### Click Country


func myMapView(_ myMapView: GMSMapView, didTap overlay: GMSOverlay) {
    print("User Tapped Layer: \(overlay)")
}
    
asked by Eloyu F.Bent 30.05.2017 в 20:39
source

2 answers

0

Solved!

It seems that the drop-down menu.

 RevealViewController 

is failing me when I apply the

GSMapViewDelegate. 

Remember to add this:

 myMapView.delegate = self

Without this menu it works correctly, although the text that I receive in the console is the complete information of the polygon and not the text of the polygon.

I'm still working to see if I can change this.

Thank you and greetings.

    
answered by 04.06.2017 в 19:13
0

Finally. I added the following property to the GMSPolygon

 polygonEspaña.title = "España"

and the function

func mapView (_mapView: GMSMapView, didTap overlay: GMSOverlay) {

    print("\(overlay.title)")

Now when I click on the country I get: Optional ("Spain")

    
answered by 06.06.2017 в 18:13