The NY Times covers the location infrastucture with a focus on Skyhook Wireless and how it does triangulation:
When an iPhone owner starts up an application that involves location — like the restaurant finder Urbanspoon or the forecast service WeatherBug — the phone calculates whether it is likely to get the best and fastest information from its own GPS chip or from Skyhook’s system. Skyhook says it can provide a fix on location in seconds, versus up to a minute for GPS, although Skyhook is less useful in areas with few Wi-Fi networks.
Skyhook checks a list of nearby Wi-Fi access points and cell towers against its database and triangulates the device’s location within 30 to 60 feet. The company says it is not connecting to those Wi-Fi networks, just detecting their presence. (As a backup, the iPhone can also use cell tower information from Google.)
In addition it appears that location is coming to the browser in the iPhone 3.0 update. That means websites will be able to tap location without users having to manually enter it and that publishers will get access to user location without having to build a "native app."
Location in the mobile browser is a parallel development to location on the desktop browser.