Attached you find a small project which returns if a point is inside the polygon, in the surrounding with a given distance or outsides the surrounding.

It is an evolution of

this project.

The routine checks first if the point is in the polygon and then check if the distance of the point to the each polygon line is smaller than the given distance.

The equations are general graphic equations not exactly for maps.

But as Erel alrady pointed out:

*If the polygon is not too large then you can ignore the fact that the coordinates system is not Euclidean*
The red lines show the cursor.

The yellow line shows the surrounding distance used (shown only on one side).

View attachment 42597
The coordinates of the polygon vertexes are saved in two arrays of Doubles.

For lat/long coordinates you could calculate the distance like this.

DistanceDegrees = DistanceKiloMeters / 6371 * 180 / cPi

DistanceDegrees = DistanceMiles / 3959 * 180 / cPi