Geolocation - start tracking when on water

I have an idea for a boating app and want to start tracking location when the device is on water. I’ve had a look at the geolocation libraries and can’t see how this might be possible. Can anyone point me in the right direction for how to achieve this?