I have a GMSMutablePath object containing coordinates that I display visually on the screen with a GMSPolyLine. I want the user to be able to tap on a line segment (spanning two coordinates) and have the app create another node at the midpoint of that segment.
I use didTapOverlay method to get the touch event, but unfortunately that just gives the poly line as a whole. How can I find out what line segment was tapped so I know where to insert the new coordinate in the GMSMutablePath array?
I've found a work around for this, but if anyone knows how to do this properly I'd love to hear it!!
Basically, instead of drawing a single polyline to represent the path, I drew a separate line between each coordinate in the path. I subclassed polyline and added a property "positionInPath", which I set when I created the line. In didTapOverlay, I used this property to determine where to insert the new coordinate in the GMSMutablePath.
Hope that helps someone!