Extended profile display

The display of buttons in the company profile is required when you use API 2GIS.

Buttons

NameWhen shownURL template
Directions toThere is “point”:{“lon”,“lat”}https://2gis.ru/city/{{ project_id } /center/{{ lon }}%2C{{ lat }}/zoom/17/routeTab/to/{{ lon }}%2C{{ lat }}%E2%95%8E{{ name|url_encode }}?
Directions fromThere is “point”:{“lon”,“lat”}https://2gis.ru/city/{{ project_id } /center/{{ lon }}%2C{{ lat }}/zoom/17/routeTab/from/{{ lon }}%2C{{ lat }}%E2%95%8E{{ name|url_encode }}?utm_source=profile&utm_medium=route_from&utm_campaign=partnerapi
Find entranceThere is “point”:{“lon”,“lat”}https://2gis.ru/city/{{ project_id }}/firm/{{ id }}/entrance/center/{{ lon }}%2C{{ lat }}/zoom/17?utm_source=profile&utm_medium=entrance&utm_campaign=partnerapi
PhotosThere is “flags”:{“photos”} and its value is truehttps://2gis.ru/city/{{ project_id }}/firm/{{ id }}/photos/{{ id } /center/{{ lon }}%2C{{ lat }}/zoom/17?utm_source=profile&utm_medium=photo&utm_campaign=partnerapi
ReviewsAlwayshttps://2gis.ru/city/{{ project_id }}/firm/{{ id }}?utm_source=profile&utm_medium=review&utm_campaign=partnerapi
Services and pricesThere is “external_content”: [{“url”,“type”}], type takes the “booklet” value{{ url }}?utm_source=profile&utm_medium=booklet&utm_campaign=partnerapi

Template

Using bootstrap and twig, we will get the following template:

<div class="container">
    {% set baseUrl = "https://2gis.ru/city/{#project_id}" %}
            {% set centerPart = "center/{#lon}%2C{#lat}/zoom/17" %}
            {% set booklet_url = "" %}
            {% for external_content in content %}
            {% if content.type == "booklet" %}
            {% set booklet_url = content.url %}
            {% endif %}
            {% endfor %}

            <div class="btn-group" role="group" aria-label="...">
                <a target="_blank" class="btn btn-default" href="{{ baseUrl }}/{{ centerPart }}/routeTab/from/{{ point.lon }}%2C{{ point.lat }}%E2%95%8E{{ name|url_encode|replace({'/', '\xA6'}) }}?utm_source=profile&utm_medium=route_from&utm_campaign=partnerapi" role="button" title="Route by car or public transport from {{ name }}">
                    <span class="glyphicon glyphicon-road" aria-hidden="true"></span> Directions from
                </a>
                <a target="_blank" class="btn btn-default" href="{{ baseUrl }}/{{ centerPart }}/routeTab/to/{{ point.lon }}%2C{{ point.lat }}%E2%95%8E{{ name|url_encode|replace({'/', '\xA6'}) }}?utm_source=profile&utm_medium=route_to&utm_campaign=partnerapi" role="button" title="Route by car or public transport to {{ name }}">to</a>
            </div>
            {% if flags.photos %}
            <a target="_blank" class="btn btn-default" href="{{ baseUrl }}/firm/ {id } /photos/{{ id } / {centerPart }}?utm_source=profile&utm_medium=photo&utm_campaign=partnerapi" role="button" title="Photos of services and products {{ name }}">
                <span class="glyphicon glyphicon-camera" aria-hidden="true"></span> See photos
            </a>
            {% endif %}
            {% if booklet_url %}
            <a target="_blank" class="btn btn-default" href="{{ booklet_url }}?utm_source=profile&utm_medium=booklet&utm_campaign=partnerapi" role="button" title="See the list of products, services and prices of the {{ name }} company">
                <span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Services and prices
            </a>
            {% endif %}
            <a target="_blank" class="btn btn-default" href="{{ baseUrl }}/firm/ {ID} /entrance/{{ centerPart }}?utm_source=profile&utm_medium=entrance&utm_campaign=partnerapi" role="button" title="Entrance to {{ name }} company">
                <span class="glyphicon glyphicon-home" aria-hidden="true"></span> Find entrance
            </a>
</div>

Example

For example, for Venice company (141266769589326)

The request is https://catalog.api.2gis.com/2.0/catalog/branch/get?key=123456789&id=141266769589326&fields=items.point,items.flags,items.external_content

We get the API response and generate the following set of buttons: