Need help to make measure tool for map

I need help to make a tool for measuring function in a map. A textfield should follow the cursor and tell the distance to a point in the map.