I am parsing a polygon from a KML file to an MKMap and when a user add an annotation (point) on the map I need to calculate the shortest displacement between the annotation to the polygon (not to on of the polygon points but to his bounds).
Heres an example :
I have the coordinates for each point of the polygon and I have the coordinates of the annotation.
What I had in mind is to run through all the points coordinates and try to calculate the perpendicular line from the annotation to each line and then compare the displacements, then calculate all the displacements to the polygon points from my annotation and choose the smallest displacement but I am sure there is a much better and simpler solution.
I was searching for some ready to use framework but with no success.