|
|
Строка 2: |
Строка 2: |
| <widget> | | <widget> |
| <html> | | <html> |
| <div id="dg-floors-container" style="width: 960px; height: 600px; border: 1px solid #eee; margin: 10px auto;"></div> | | <div id="container" style="width: 800px; height: 600px;"></div> |
| <script src="https://floors-widget.api.2gis.ru/loader.js" charset="utf-8"></script> | | <script |
| <script>
| | charset="utf-8" |
| document.addEventListener('DOMContentLoaded', function() {
| | src="https://floors-widget.api.2gis.ru/loader.js" |
| // Получаем complexId без значения по умолчанию
| | id="dg-floors-widget-loader" |
| const complexId = '{{{complexId}}}'; | | ></script> |
| const container = document.getElementById('dg-floors-container');
| | <script charset="utf-8"> |
|
| |
| // Проверка обязательного параметра
| |
| if (!complexId || complexId === '{{{complexId}}}') {
| |
| container.innerHTML = `
| |
| <div style="
| |
| color: #d32f2f;
| |
| padding: 20px;
| |
| text-align: center;
| |
| font-family: Arial, sans-serif;
| |
| background: #ffebee;
| |
| border-radius: 4px;
| |
| ">
| |
| <strong>Ошибка:</strong> Не указан обязательный параметр complexId.<br>
| |
| Используйте: {{#widget:${mw.config.get('wgTitle')}|complexId=123456789}}
| |
| </div>
| |
| `;
| |
| return;
| |
| }
| |
| | |
| // Валидация формата ID (только цифры)
| |
| if (!/^\d+$/.test(complexId)) {
| |
| container.innerHTML = `
| |
| <div style="
| |
| color: #d32f2f;
| |
| padding: 20px;
| |
| text-align: center;
| |
| font-family: Arial, sans-serif;
| |
| background: #ffebee;
| |
| border-radius: 4px;
| |
| ">
| |
| <strong>Ошибка:</strong> Неверный формат complexId (должны быть только цифры).<br>
| |
| Получено: ${complexId}
| |
| </div>
| |
| `;
| |
| return;
| |
| }
| |
| | |
| // Инициализация виджета 2GIS
| |
| DG.FloorsWidget.init({ | | DG.FloorsWidget.init({ |
| container: 'dg-floors-container',
| | width: '960px', |
| width: '100%',
| | height: '600px', |
| height: '600px',
| | initData: { |
| initData: {
| | complexId: '141265769440516', |
| complexId: complexId
| | }, |
| }
| |
| }); | | }); |
| });
| |
| </script> | | </script> |
| </html> | | </html> |
| </widget> | | </widget> |
| </includeonly> | | </includeonly> |
|
| |
| <noinclude> | | <noinclude> |
| [[Категория:Виджеты]]
| |
|
| |
| == Использование == | | == Использование == |
| === Обязательный параметр ===
| | Используйте виджет с параметром complexId: |
| Вызовите виджет с параметром complexId (ID здания из 2GIS):
| |
|
| |
|
| <pre>
| | Где 123456789 - ID комплекса в 2GIS. |
| {{#widget:{{PAGENAME}}|complexId=<span style="color:red">ваш_id_здания</span>}}
| |
| </pre>
| |
|
| |
|
| === Где найти complexId ===
| | [[Категория:Виджеты]] |
| 1. Откройте нужное здание в <a href="https://2gis.ru">2GIS</a>
| |
| 2. Скопируйте цифровой ID из адресной строки:
| |
| <code>https://2gis.ru/firm/<strong>123456789012345</strong>/tab/inside</code>
| |
| | |
| === Пример ===
| |
| {{#widget:{{PAGENAME}}|complexId=141373143573143}}
| |
| </noinclude> | | </noinclude> |
Использование
Используйте виджет с параметром complexId:
Где 123456789 - ID комплекса в 2GIS.