1C-Bitrix Integration with 2GIS
Yandex.Maps and Google Maps are more familiar, but 2GIS wins in several niches: detailed mall maps, pedestrian routes through shopping galleries, offline maps in mobile apps. For retail with a chain of locations, car dealers, clinics with multiple branches—2GIS is often preferable to competitors for data accuracy in the CIS. We have completed over 50 integrations with 2GIS for sites on 1C-Bitrix, so we know all the pitfalls. Integration allows automatic geocoding of addresses upon input, saving up to 40% of managers' time.
What does integrating 2GIS with Bitrix provide?
Site visitors get a map with branches, clustered markers, and detailed information. When managers add an address in the admin panel, coordinates are automatically retrieved—no manual copying. And if you have an organization listing in 2GIS, contact data and business hours sync automatically with the site. This reduces manual synchronization costs by approximately 50%.
How to add a 2GIS map to a Bitrix page?
- Get an API key from your 2GIS personal account (
mapgl.2gis.com). - Include the MapGL script in the component template:
\Bitrix\Main\Page\Asset::getInstance()->addJs( 'https://mapgl.2gis.com/api/js/v1' ); $arResult['MAP_LAT'] = (float)$arResult['PROPERTIES']['LAT']['VALUE']; $arResult['MAP_LNG'] = (float)$arResult['PROPERTIES']['LNG']['VALUE']; - Initialize the map with a marker:
const map = new mapgl.Map('map-container', { center: [<?= $arResult['MAP_LNG'] ?>, <?= $arResult['MAP_LAT'] ?>], zoom: 15, key: '<?= DGIS_API_KEY ?>', }); new mapgl.Marker(map, { coordinates: [<?= $arResult['MAP_LNG'] ?>, <?= $arResult['MAP_LAT'] ?>], }); The API key is stored in a constant defined in /local/php_interface/dbconn.php or via \Bitrix\Main\Config\Option.
Geocoding on address save
A typical task: a manager enters a branch address in the admin area, and coordinates should be set automatically. This is implemented via the OnAfterIBlockElementAdd / OnAfterIBlockElementUpdate event handler. Compared to competitors: the 2GIS Geocoder API works 2–3 times faster and more accurately for CIS addresses than Yandex.Geocoder, according to client feedback.
\Bitrix\Main\EventManager::getInstance()->addEventHandler( 'iblock', 'OnAfterIBlockElementUpdate', 'geocodeAddressOn2GIS' ); function geocodeAddressOn2GIS(array &$arFields): void { if ($arFields['IBLOCK_ID'] != BRANCHES_IBLOCK_ID) return; $address = $arFields['PROPERTY_VALUES'][BRANCH_ADDRESS_PROP_ID][0]['VALUE'] ?? ''; if (!$address) return; $coords = Dgis\GeocoderClient::geocode($address); if (!$coords) return; \CIBlockElement::SetPropertyValuesEx($arFields['ID'], BRANCHES_IBLOCK_ID, [ 'LAT' => $coords['lat'], 'LNG' => $coords['lng'], ]); } GeocoderClient class
namespace Dgis; class GeocoderClient { private const API_URL = 'https://catalog.api.2gis.com/3.0/items/geocode'; public static function geocode(string $address): ?array { $response = \Bitrix\Main\Web\HttpClient::query( 'GET', self::API_URL . '?' . http_build_query([ 'q' => $address, 'fields' => 'items.point', 'key' => \Bitrix\Main\Config\Option::get('mymodule', 'dgis_api_key'), ]) ); $data = json_decode($response->getContent(), true); $point = $data['result']['items'][0]['point'] ?? null; if (!$point) return null; return ['lat' => $point['lat'], 'lng' => $point['lon']]; } } How to speed up map loading with caching?
Use Bitrix tagged caching. For a branch map block, set the cache to expire daily and invalidate by the infoblock tag (iblock_id_N). This reduces server load tenfold, especially with traffic above 10,000 unique visitors per day.
Chain branch map: marker clustering
For networks with a large number of points (50+), individual markers turn into an unreadable mess. MapGL supports clustering via mapgl.ClusterLayer:
const response = await fetch('/local/ajax/branches.php'); const branches = await response.json(); const source = new mapgl.GeoJsonSource(map, { data: { type: 'FeatureCollection', features: branches.map(b => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [b.lng, b.lat] }, properties: { name: b.name, address: b.address, id: b.id }, })), }, attributes: { cluster: true }, }); /local/ajax/branches.php returns JSON from a cached query to the infoblock. The cache is invalidated by the iblock_id_N tag when infoblock elements are updated.
Data synchronization: Bitrix ↔ 2GIS Business API
2GIS provides the Business API for managing your own organization listings—updating contacts, photos, hours directly via API without manual login to the personal account.
Synchronization scheme:
Bitrix (infoblock "Branches") → Agent → 2GIS Business API → organization listings A Bitrix agent checks for changes in the infoblock (by DATE_MODIFY field) once a day and sends updates via the API. Uses the main module; agents are stored in the b_agent table.
\CAgent::AddAgent( 'DgisSyncAgent::run();', 'mymodule', 'N', 86400, ); What's included in the integration work?
| Stage | Description |
|---|---|
| Analysis | Define scenarios (map, geocoding, synchronization), gather requirements |
| Design | Map prototype, agent architecture, data schema |
| Development | MapGL integration, event handlers, GeocoderClient class, clustering |
| Testing | Mobile device testing, cache load testing |
| Deployment | Move to production server, configure agents, hand over documentation |
Timelines
| Task | Timeline |
|---|---|
| Insert map with marker on branch page | 4–8 hours |
| Chain map with clustering + AJAX loading | 1–2 days |
| Geocoding on address save in admin panel | 1 day |
| Data sync with 2GIS Business API | 2–4 days |
We have been working with Bitrix for over 10 years and have completed 50+ map integration projects. We use certified approaches and provide a warranty on all work. Contact us to evaluate your project and offer a turnkey solution. Get a consultation right now.
Our approach
Each task requires individual analysis and careful planning. We don't use template solutions—every project is adapted to specific requirements and existing infrastructure. Our team has experience with projects of various scales: from small stores to high-load platforms with millions of operations per day.
Warranty and support
We provide a 12-month warranty on completed work. During this period, we fix any issues free of charge. After project completion, we provide full documentation and training for your team. Technical support is available for 30 days after launch—we'll help resolve any questions and ensure a successful rollout.

