Location selection interface without directories using Google maps

    When creating various web services, it becomes necessary to indicate the address or geographical location on the map. For example, when creating a service for the sale of real estate, you need navigation 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 sequentially select the name of the country, city, district, etc. Such an interface requires the preliminary filling of directories of names, support, updating.
    An option is proposed for implementing such an interface without filling out directories using the Google Maps Api functionality.

    Background


    Before the advent of on-line maps, the issue of choosing a location was solved by creating various directories of geographical names. When creating an international service, the situation is complicated by the need to translate names, store values ​​in different languages.
    Given that in Russia alone the number of settlements is tens of thousands, one can imagine the problems that arise in this case.
    Many followed a simpler path: they gave users the opportunity to independently enter the names of settlements and addresses. This approach is certainly simpler, but fraught with differences in spelling of names. For example, the name of the city of St. Petersburg can be written in many ways: St. Petersburg, S. Petersburg, Petersburg, etc.
    In this case, there is a need to verify the input data, or the inability to correctly group information.

    Current situation


    With the advent of cartographic online services, the situation began to change.
    Google Maps was the first to provide a free API for using maps on sites.
    Many limited themselves to simply adding the ability to specify the exact position on the map to the existing interface. But even this opportunity greatly improved the presentation of information. It became possible to display the relative position of many objects on the map using markers, similarly to how positions on paper maps were previously marked with pins ...
    However, entering information for many previously existing services still required a consistent selection of names from the lists, and only after this indication of the position on the map.
    Innovations
    When developing a serviceFor renting villas and apartments , the author came up with the idea of ​​creating an interface for adding objects without using directories of geographical names.
    One of the functions of the Google Maps API is to determine the address of a specified point, the so-called Geocoding. With its help, when indicating the location of the object on the map, you can get the address in a specific format. Using the obtained data, it is possible to create and fill in the corresponding structure of the directory of geographical names when adding an object. Accordingly, there is no need for the preliminary creation of directories, the choice of names when entering.
    Since the service being created is international, it was necessary to be able to enter and store information in different languages.
    After studying the specifications of the formats of the received data, an interface was developed that meets the necessary requirements.

    Benefits


    From the user's point of view, adding an object using this interface is easier than in the traditional case. The number of necessary actions is reduced, just find your object on the map.

    Consider the algorithm of its operation:
    1. When adding an object, the user enters the address or keyword of the desired location in the search bar, clicks “Search”.



    2. If such an address exists, a map is displayed on which the marker indicates the position of the object.
    in this case, the full address of the object is displayed in the search bar, while the coordinates and geo-structural data in 2 languages ​​are stored in hidden form fields.



    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 the map independently. (in this case, the nearest settlement will be determined)

    The received address information contains all the necessary data to preserve the location of the object, taking into account the administrative-territorial division, writing in Russian and English.
    When an object is saved in the site database, an object is linked to a directory of geographical names if this object is not the first in this structure, or a new record is added to the directory.
    As the base is filled with new objects, the directory of geographical names is also filled.



    Since all names are associated with a single database of Google names, there are no problems with 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.

    Also popular now: