L
L
lovesuper2013-06-04 19:32:26
JavaScript
lovesuper, 2013-06-04 19:32:26

Dynamic loading of streets and house numbers in the city in the field during registration?

Good evening! Such here problem: it is necessary to organize on page of registration of the visitor registration of its place of residing. There are three conditional fields: City, Street, House. I would like to make it so that when entering a value in the City field in the Street field, the streets of this city are loaded, when choosing from Streets, the houses on these streets (house numbers) are loaded. I searched, but could not find any api so that you can simply get the value of the city - its streets. Help advice, friends! I do it on js, although I have always dealt only with the backend :) Therefore, I am a little incompetent in matters of working with the frontend and js.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Koreysha, 2013-06-05
@Iktash

Did something like this. Downloaded FIAS in xml format. Further a script which puts all this to me in base. Then simple Ajax. The base is made not so conveniently. Personally, I rely on the "levels" they provide to each object.
The following levels of address objects are conditionally distinguished:
1 - the level of the region
2 - the level of the autonomous district
3 - the level of the district
4 - the level of the city
5 - the level of the intracity territory
6 - the level of the settlement
7 - the street level
90 - the level of additional territories
91 - the level of objects subordinated to additional territories
Each "entity" has its level, id, and parent id. I didn't use the rest.
The unpacked archive takes a little more than 10G. Base about 1G At me it turned out.
If you need more details, please get in touch.

V
Viktor Kuznetsov, 2013-06-04
@janitor

If in Russia, then you can use the KLADR base (it seems to be called that). When choosing a city, make a request to the server to learn the streets for this city, then show them when necessary

S
safright, 2013-06-06
@safright

For js implementation, autocomplete or, if bootstrap is used, typeahead can be useful .
And for the server part - yes, only FIAS should be parsed into the database. A few months ago I didn’t find any sane api even for cities, let alone for streets / houses. 2GIS and Yandex, apparently, use their own geo-databases for search and auto-completion, so you should not rely on them too much.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question