but it can be a function of the map. (It's not that hard)

Basically, you use Dijkstra's (or Floyd's) algorithm to find the shortest path - with movement modifiers representing the resistance.

But I'd probably put it in it's own class - only because you want to pass into it the movement types available to the unit so that it can compute shortest possible distance regardless of the type of the unit.