Вопрос

I have to group all users registering to my site into metro areas. A metro area is defined a proximity to one of the world's 100 most populous cities.

In my proposed solution the user will be presented with 2 dropdowns. One for country and one for cities. That seems like the best UX. I was also thinking about using html5 browser location API to pre-select some locations on the dropdowns.

Has anyone done something similar before and how did you approach it?

sub question: how would you store this data

Это было полезно?

Решение

ip-geolocation is often not extramly exact.

I would force user to enter country, city and zip.

And pre fill form with data from browser location api.

In database i would store country, city, zip, and lat long.

Find matching city + zip by lat long and backword is very easy with google geocoder api. https://developers.google.com/maps/documentation/geocoding/

Then you only needs the lat long values of big citys for search in area. Easyes is to search in squre not in circle. But if you realy needs a cirty, you have to use a databse with gis functionalety. http://postgis.refractions.net/

Другие советы

I would not use geolocation. It doesn't always work the same in all browsers and isn't always reliable for every situation.

I have done something similar and I used area code. Some big metro areas have overlapping area codes but if you use the major area code for the metro areas you can find a good way to attack this. Some states only have several major area codes.... some go up much higher but you know that the more area codes, the more populated the area is (typically). The more area codes attached to a metro area could be used as another factor to determine populous cities.

Most users might not want to give city or zip but will give an area code on registration. You can assign area codes to states and also area codes to metro areas.

This map should help if you decide to approach it that way as an extra value http://www.nanpa.com/area_code_maps/ac_map_static.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top