This commit is contained in:
2025-09-23 20:13:51 +05:00
commit 234525435d
21 changed files with 25832 additions and 0 deletions

376
working_map_2gis.html Normal file
View File

@@ -0,0 +1,376 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Карта учебных заведений Челябинска - 2GIS</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;
padding: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
}
.header {
background: linear-gradient(135deg, #2c5aa0 0%, #764ba2 100%);
color: white;
padding: 20px;
text-align: center;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.header h1 {
margin: 0;
font-size: 2.2em;
font-weight: 300;
}
.header p {
margin: 10px 0 0 0;
opacity: 0.9;
font-size: 1.1em;
}
.controls {
background: white;
padding: 15px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
align-items: center;
}
.filter-btn {
padding: 8px 16px;
border: 2px solid #2c5aa0;
background: white;
color: #2c5aa0;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 14px;
font-weight: 500;
}
.filter-btn:hover {
background: #2c5aa0;
color: white;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(44, 90, 160, 0.3);
}
.filter-btn.active {
background: #2c5aa0;
color: white;
}
.stats {
text-align: center;
color: #666;
font-size: 14px;
margin-left: 20px;
background: #f0f0f0;
padding: 5px 10px;
border-radius: 15px;
}
#map {
width: 100%;
height: calc(100vh - 180px);
border: 2px solid #ddd;
}
.error-message {
background: #ffe6e6;
border: 1px solid #ff9999;
color: #cc0000;
padding: 15px;
margin: 20px;
border-radius: 5px;
text-align: center;
}
.loading {
background: #e6f3ff;
border: 1px solid #99ccff;
color: #0066cc;
padding: 15px;
margin: 20px;
border-radius: 5px;
text-align: center;
}
@media (max-width: 768px) {
.header h1 {
font-size: 1.8em;
}
.controls {
padding: 10px;
}
.filter-btn {
font-size: 12px;
padding: 6px 12px;
}
.stats {
margin-left: 0;
margin-top: 10px;
width: 100%;
}
}
</style>
</head>
<body>
<div class="header">
<h1>🎓 Карта учебных заведений Челябинска</h1>
<p>Среднее специальное и высшее образование • Powered by 2GIS</p>
</div>
<div class="controls">
<button class="filter-btn active" onclick="filterInstitutions('all')">🏛️ Все</button>
<button class="filter-btn" onclick="filterInstitutions('университет')">🎓 Университеты</button>
<button class="filter-btn" onclick="filterInstitutions('институт')">🏛️ Институты</button>
<button class="filter-btn" onclick="filterInstitutions('колледж')">📚 Колледжи</button>
<button class="filter-btn" onclick="filterInstitutions('техникум')">🔧 Техникумы</button>
<div class="stats">
<span id="showing-count">30</span> из 30 учреждений
</div>
</div>
<div id="map-container">
<div class="loading" id="loading">
⏳ Загрузка карты 2GIS...
</div>
<div id="map" style="display: none;"></div>
</div>
<script>
// Данные об учебных заведениях
const institutions = [
{
"name": "Южно-Уральский государственный университет",
"address": "проспект Ленина, 76, Челябинск",
"latitude": 55.1549,
"longitude": 61.4289,
"phones": ["+7 (351) 267-90-90"],
"categories": ["Университет", "Высшее образование"],
"type": "университет"
},
{
"name": "Челябинский государственный университет",
"address": "ул. Братьев Кашириных, 129, Челябинск",
"latitude": 55.1605,
"longitude": 61.4025,
"phones": ["+7 (351) 799-70-02"],
"categories": ["Университет", "Высшее образование"],
"type": "университет"
},
{
"name": "Челябинский государственный педагогический университет",
"address": "проспект Ленина, 69, Челябинск",
"latitude": 55.1545,
"longitude": 61.4267,
"phones": ["+7 (351) 216-56-01"],
"categories": ["Университет", "Педагогическое образование"],
"type": "университет"
},
{
"name": "Уральский государственный университет физической культуры",
"address": "ул. Орджоникидзе, 1, Челябинск",
"latitude": 55.1674,
"longitude": 61.3988,
"phones": ["+7 (351) 237-04-54"],
"categories": ["Университет", "Физическая культура"],
"type": "университет"
},
{
"name": "Челябинский институт экономики и права",
"address": "ул. Свободы, 155, Челябинск",
"latitude": 55.1890,
"longitude": 61.3176,
"phones": ["+7 (351) 217-18-18"],
"categories": ["Институт", "Экономика и право"],
"type": "институт"
},
{
"name": "Челябинский государственный институт культуры",
"address": "ул. Орджоникидзе, 36а, Челябинск",
"latitude": 55.1699,
"longitude": 61.4018,
"phones": ["+7 (351) 263-83-18"],
"categories": ["Институт культуры", "Высшее образование"],
"type": "институт"
},
{
"name": "Челябинский медицинский колледж",
"address": "ул. Свободы, 159а, Челябинск",
"latitude": 55.1901,
"longitude": 61.3164,
"phones": ["+7 (351) 232-72-01"],
"categories": ["Медицинский колледж", "Среднее специальное образование"],
"type": "колледж"
},
{
"name": "Челябинский технологический колледж",
"address": "ул. Машиностроителей, 23, Челябинск",
"latitude": 55.1267,
"longitude": 61.4567,
"phones": ["+7 (351) 729-99-60"],
"categories": ["Технологический колледж", "Среднее специальное образование"],
"type": "колледж"
},
{
"name": "Челябинский юридический колледж",
"address": "ул. Цвиллинга, 60, Челябинск",
"latitude": 55.1645,
"longitude": 61.4156,
"phones": ["+7 (351) 266-55-20"],
"categories": ["Юридический колледж", "Среднее специальное образование"],
"type": "колледж"
},
{
"name": "Челябинский автотранспортный техникум",
"address": "ул. Монакова, 33, Челябинск",
"latitude": 55.1123,
"longitude": 61.4234,
"phones": ["+7 (351) 721-81-67"],
"categories": ["Автотранспортный техникум", "Среднее специальное образование"],
"type": "техникум"
}
];
let myMap;
let allMarkers = [];
function showError(message) {
document.getElementById('loading').innerHTML = `
<div class="error-message">
${message}
<br><small>Проверьте подключение к интернету или попробуйте позже</small>
</div>
`;
}
function initializeMap() {
console.log('Инициализация карты 2GIS...');
try {
// Создаем карту
myMap = DG.map('map', {
center: [55.1644, 61.4291], // Центр Челябинска
zoom: 11
});
console.log('Карта создана успешно');
document.getElementById('loading').style.display = 'none';
document.getElementById('map').style.display = 'block';
// Добавляем маркеры
addMarkersToMap();
} catch (error) {
console.error('Ошибка создания карты:', error);
showError('Не удалось создать карту: ' + error.message);
}
}
function addMarkersToMap() {
console.log('Добавляем маркеры на карту...');
institutions.forEach((institution, index) => {
try {
const marker = DG.marker([institution.latitude, institution.longitude])
.addTo(myMap);
// Создаем содержимое всплывающего окна
const popupContent = `
<div style="max-width: 300px;">
<h3 style="margin: 0 0 10px 0; color: #2c5aa0;">${institution.name}</h3>
<p style="margin: 5px 0;"><strong>📍 Адрес:</strong> ${institution.address}</p>
<p style="margin: 5px 0;"><strong>📋 Категории:</strong> ${institution.categories.join(', ')}</p>
${institution.phones.length ? `<p style="margin: 5px 0;"><strong>📞 Телефон:</strong> ${institution.phones.join(', ')}</p>` : ''}
</div>
`;
marker.bindPopup(popupContent);
marker.institutionData = institution;
allMarkers.push(marker);
} catch (error) {
console.error('Ошибка создания маркера для', institution.name, ':', error);
}
});
console.log(`Добавлено ${allMarkers.length} маркеров`);
// Подгоняем карту под все маркеры
if (allMarkers.length > 0) {
setTimeout(() => {
try {
const group = DG.featureGroup(allMarkers);
myMap.fitBounds(group.getBounds(), {padding: [20, 20]});
} catch (error) {
console.error('Ошибка подгонки границ:', error);
}
}, 1000);
}
}
function filterInstitutions(filterType) {
// Обновляем активную кнопку
document.querySelectorAll('.filter-btn').forEach(btn => btn.classList.remove('active'));
event.target.classList.add('active');
let visibleCount = 0;
allMarkers.forEach(marker => {
const institution = marker.institutionData;
let shouldShow = false;
if (filterType === 'all') {
shouldShow = true;
} else {
shouldShow = institution.type === filterType ||
institution.name.toLowerCase().includes(filterType) ||
institution.categories.some(cat => cat.toLowerCase().includes(filterType));
}
if (shouldShow) {
myMap.addLayer(marker);
visibleCount++;
} else {
myMap.removeLayer(marker);
}
});
// Обновляем счетчик
document.getElementById('showing-count').textContent = visibleCount;
}
// Инициализация при загрузке страницы
document.addEventListener('DOMContentLoaded', function() {
console.log('Страница загружена, проверяем 2GIS API...');
if (typeof DG === 'undefined') {
console.error('2GIS API не загружен');
showError('2GIS API недоступен');
return;
}
DG.then(function() {
console.log('2GIS API готов к использованию');
initializeMap();
}).catch(function(error) {
console.error('Ошибка инициализации 2GIS API:', error);
showError('Не удалось инициализировать 2GIS API: ' + error.message);
});
});
</script>
</body>
</html>