RunKeeper has an iPhone app for 3G versions (with GPS) that tracks your runs, rides, whatever, via GPS.
It allows you to upload your distances for each workout, share it with friends online, etc.  On a full battery charge, it’ll track up to a three hour ride while letting you listen to music.
They offer a free, ad-supported version and a pro version with no ads and offers audio cues and voice feedback.
There are a few downsides to the program.  First, if you get a call, it pauses the program and stops tracking your progress, then gives you the option to resume tracking after your phone call.  Second, due to restrictions of the iPhone itself, you can’t run any other third party apps while using RunKeeper.  Also, if you exit out of RunKeeper while it’s tracking, it pauses tracking until you’re back in it…so you can’t snap a photo of that hot Italian girl that rides to class in 4″ heels without missing a bit of distance (one might argue it could be worth it).
They have maps planned for realtime viewing on the iPhone, but for now you can view maps of your ride online when you log in.