I'm developing an application in swift 3.0 with the Google Maps SDK. I have to say this is the first time I work with this SDK and it is so I need a little help. I think what I ask you will be easy for you. What I want to do is when the user enters a map editing mode (like this page http://www.birdtheme.org/useful/v3tool.html ). He can do two things:
First he could draw polygons on the map (to mark the boundaries of a farmer field). I want the user to press a point on the map and generate a line until the next point. In this way, he will generate lines until the polygon is closed. My code for drawing polygon attach below. But the problem is that it never closes the polygon.But the problem is that I want it when the beginning of the line and the end are touched or the lines cross, close the polygon.How do I do it? As you see in the picture, I can draw infinite lines.
let pathEditField = GMSMutablePath() func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) { if modeEditing { pathEditField.add(coordinate) let polyline = GMSPolyline(path: pathEditField) polyline.map = mapView } }
Second, once the polygon is drawn, the vertices are highlighted in some way, then you can move that vertex to finish adjusting.
I leave you a screenshot, so that you get an idea where the user can create the polygon and where to adjust the vertices.
The problem is that I do not know how to do it besides I can not find documentation for it. My question is, do you know any tutorial where something similar is done? Or can you start the code a bit without writing it?
The user can determine the limits of his land parcel by creating a polygon and adjusting it afterwards.
Thank you very much.
Use this code to create polygon GoogleMaps documentaion