When creating various web services, it is necessary to specify the address or geographical location on the map. For example, when creating a service for the sale of real estate, you need to navigate and search for objects in a given region, city, district.
As a rule, when adding a new object, the user is given the opportunity to consistently select the name of the country, city, district, etc. Such an interface requires pre-filling directories names, support, updating.
The proposed implementation of such an interface without filling out reference books, using the functional Google Maps Api.
Prehistory
Before the advent of online maps, the choice of location was decided by creating various geographical names directories. When creating an international service, the situation is complicated by the need to translate the names, store the values ​​in different languages.
If we consider that only in Russia the number of settlements is tens of thousands, you can imagine the problems arising from this.
Many went in a simpler way: they gave users the opportunity to enter the names of settlements and addresses on their own. This approach is certainly easier, but is fraught with differences in the spelling of names. For example, the name of the city of St. Petersburg can be written in many ways: St. Petersburg, St. Petersburg, St. Petersburg, etc.
In this case, there is a need to verify the input data, or the inability to properly group information.
Current situation
With the advent of cartographic on-line services, the situation began to change.
Google Maps was the first to provide a free API for using maps on sites.
Many have limited themselves to simply adding to the existing interface an additional opportunity to indicate the exact position on the map. But even this opportunity has greatly improved the presentation of information. It was possible to display the relative position of many objects on the map with the help of markers, similarly, to how the positions on paper maps were earlier marked with pins ...
Nevertheless, the input of information for many previously existing services, still required a consistent choice of names from the lists, and only after this indication of the position on the map.
Innovations
When developing a
rental service
for villas and apartments , the author had the idea of ​​creating an interface for adding objects without using geographical names directories.
One of the functions of the Google Maps API is to determine the address of the specified point, the so-called Geocoding. With its help, when indicating the position of an object on a map, it is possible to obtain an address in a specific format. Using the data obtained, you can create and fill in the corresponding structure of the directory of geographic names directly when adding an object. Accordingly, there is no need to pre-create directories, the choice of names when entering.
Since the created service is international, the ability to enter and store information in different languages ​​was necessary.
After studying the specifications of the formats of the data received, an interface was developed that meets the necessary requirements.
')
Benefits
From the user's point of view, adding an object using such an interface is easier than in the traditional case. The number of necessary actions is reduced, you just need to find your object on the map
Consider the algorithm of his work:
1. When adding an object, the user enters the address or keyword of the desired area in the search bar, clicks "Search".

2.If such an address exists, a map is displayed on which the position of the object is marked with a marker.
the search bar displays the full address of the object, while the hidden fields of the form store the coordinates and geo-structural data in 2 languages.

3.If the object does not have an exact postal address (for example, a garden house), the user can use the “point with the cursor” function and mark the object on his own. (this will determine the nearest settlement)
The received address information contains all the necessary data to maintain the location of the object, taking into account the administrative-territorial division, writing in Russian and English.
When you save an object in the site database, an object is linked to the directory of geographical names, if the object is not the first in this structure, or a new entry is added to the directory.
As the database is filled with new objects, the geographical names directory is also filled.

Since all titles are linked to Google’s single name base, there’s no problem with the different spelling of names.
Thus, a sample of structural geo-information from the Google database related to stored objects is created in the site database.