The html5 geolocation API allows your browser to share your location using the most accurate source available. On a smartphone, this is the GPS antenna (when it's on), cell tower triangulation, or WiFi geolocation. The WiFi location works because you can register your location on sites such as Skyhook, and Google collects this data when they drive the street view cars around. On a desktop or laptop, this is usually WiFi or IP address (keep in mind you don't have to actually join the network, just be in range of one, so it could be a neighbor's). With IP addresses, you can very accurately determine the country, and a general region, since IP blocks are usually assigned to ISP's, so if you are a cable customer, you can be traced to the nearest hop from your house, which will be about a 50-100 mile radius in most of the US. For a more accurate position, here's where the privacy concerns come in. There are companies like MaxMind that gather data on individual IP addresses. In their words:
MaxMind partners with various websites where users are asked to enter some form of geographical location information. The IP address and location data are forwarded to MaxMind after all personally identifiable information have been scrubbed to protect privacy concerns. MaxMind then runs millions of these IP location pairs through a series of algorithms and programs that identify, extract, and extrapolate relevant associations between IP address and geographical information.
Source: http://www.maxmind.com/app/ip-location-explained
So think about that the next time you fill out a form online. When you put in your billing address, they are collecting your physical location and tying it to your IP address. Even if they aren't getting full address to IP lists, they could at least calculate that certain ranges apply to certain streets.