How do services like Google Latitude, through my browser, obviously through my internet connection (Ethernet not Wi-Fi), obtain my location perfectly with only my current public IP address? By asking my ISP?
[Please upvote/accept @jcrawfordor's answer, but I wanted to add some information and the comment box character limit was too small, so I decided put this as an Answer instead.]
Please note the web browser Geolocation API. You probably forgot that the first time you visited Google Latitude, you gave your browser permission to let Google Latitude access your Mac's Location Services data. For browsers that don't support the Geolocation API natively, there are downloadable browser plug-ins or Java applets that provide this kind of feature, almost always by querying your Wi-Fi card for what networks it can see around it. Skyhook's "Loki" technology is a Java applet, but since it needs to access system APIs to query your Wi-Fi card for network scan data, your browser has to ask permission before it will run Loki. Usually Java apps are completely sandboxed and don't require permission to run because they can't violate your privacy or access anything on your system.
Here's what Safari does when you first visit Google Latitude:
Here's what Safari does when you try to load Skyhook's Loki applet:
Google Latitude uses a proprietary Google service that operates on the exact same principal as the more popular Skyhook Wireless system. The software takes readings from your wifi adapter, and compares these to a database of known wireless networks and their locations, allowing for the triangulation of your position based on signal strengths. This allows the service to determine an accurate location without GPS.
The database of WiFi networks is quite extensive and comes from multiple sources. First, they likely import from public databases like WiGLE. Second, whenever a laptop running the service sees a new network, it's reported to the service. When multiple computers report a new network, its position can be triangulated based on the position of the known computers. It is fairly simple to keep a database of all wireless networks because all wireless networks (even those with the same ESSID) have a unique interface MAC address assigned by the manufacturer.
IP addresses are assigned to ISPs in blocks. If you know where a particular ISP does business then you can map a block of IP addresses to a general geographic location. It's not always perfect, though. For example, most GeoIP databases think that I'm located about 60 miles from where I actually am.
They can also judge your distance from their sever by looking at how many "hops" there are between your computer and their server and also by looking at where the hops are.
Using your IP address in conjunction with the hops data and other data sourced (for example, your system's language and time zone) they can further narrow down your location.
So, if a person's IP address were 220.123.321.234, their timezone was GMT+9, and their computer was configured for Korean then you could be pretty certain that they are in Seoul, South Korea.