问题
Say you visit Groupon from the entry point Agoura Hills, CA - how would Groupon go about referencing that town to the nearest city that has deals (like Los Angeles) and choosing that as the closest?
Is it grabbing lat/long from the location and calculating the distance from all available cities, choosing the shortest? If so, where can you get lat/long data like that for each city or an open api to use for this purpose?
回答1:
Groupon seems to use limelightnetworks as their CDN provider and most CDNs due to their distributed nature having some kind of geo-location database which they can map the request which is coming from the region. At the CDN's hands those information is easy, and site can be work with that information further. All that would be required is someway for the DNS to inform the server and this is not a new concept.
There is a also a geolocation API spec, which would allow browsers/clients to send information about the users location to the server (which the server can use for customization). Those act number of factors such as DNS, your wireless AP, etc. But that is still in draft stage and some google services use it and it requires browser support too.
来源:https://stackoverflow.com/questions/5738947/how-do-sites-like-groupon-segment-geolocation-based-on-the-cities-they-have-deal