63 lines
2.4 KiB
HTML
63 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Тест 2GIS API</title>
|
|
<script src="https://maps.api.2gis.ru/2.0/loader.js?pkg=full&key=f61cfc4b-55b7-4937-8625-c00932bee844"></script>
|
|
<style>
|
|
body { margin: 0; font-family: Arial, sans-serif; }
|
|
#map { width: 100%; height: 100vh; }
|
|
.info { position: absolute; top: 10px; left: 10px; background: white; padding: 10px; border-radius: 5px; z-index: 1000; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="info">
|
|
<h3>Тест карты 2GIS</h3>
|
|
<div id="status">Загрузка...</div>
|
|
</div>
|
|
<div id="map"></div>
|
|
|
|
<script>
|
|
const statusDiv = document.getElementById('status');
|
|
|
|
function updateStatus(message) {
|
|
statusDiv.innerHTML = message;
|
|
console.log(message);
|
|
}
|
|
|
|
updateStatus('Проверяем доступность 2GIS API...');
|
|
|
|
if (typeof DG === 'undefined') {
|
|
updateStatus('❌ 2GIS API не загружен');
|
|
} else {
|
|
updateStatus('✅ 2GIS API доступен, инициализируем карту...');
|
|
|
|
DG.then(function() {
|
|
updateStatus('✅ 2GIS API загружен успешно');
|
|
|
|
try {
|
|
const map = DG.map('map', {
|
|
center: [55.1644, 61.4291], // Центр Челябинска
|
|
zoom: 11
|
|
});
|
|
|
|
updateStatus('✅ Карта создана успешно');
|
|
|
|
// Добавляем тестовый маркер
|
|
const marker = DG.marker([55.1644, 61.4291]).addTo(map);
|
|
marker.bindPopup('Тестовый маркер в центре Челябинска');
|
|
|
|
updateStatus('✅ Карта полностью работает!');
|
|
|
|
} catch (error) {
|
|
updateStatus('❌ Ошибка создания карты: ' + error.message);
|
|
}
|
|
|
|
}).catch(function(error) {
|
|
updateStatus('❌ Ошибка загрузки 2GIS API: ' + error.message);
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |