you can go through the entire map field by field and check the distance to the point, this way finding the smallest distance and therefore the closest field.
another way would be a very simplified version of path finding where you trace starting from the initial point in all directions until you reach the field of the type you are looking for.
the first way is very easy to code. the second way is a bit more difficult but it can provide a path from the initial point to the field. let me know if you need some help with the code.