Spaces:
Running

undefined / map.html
Rovnosvet's picture
создай вкладку после "главная" - Карта, где будет на весь экран карта с отмеченными предложениями и объектами
446b956 verified
Raw History Blame Contribute Delete
8.08 kB
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Карта проектов | ЗемЭкспертAI</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://api-maps.yandex.ru/2.1/?apikey=ваш_api_ключ&lang=ru_RU"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
height: 100vh;
margin: 0;
}
#map {
width: 100%;
height: calc(100vh - 64px);
}
.marker-info {
padding: 10px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
min-width: 200px;
}
</style>
</head>
<body class="bg-primary text-gray-800">
<!-- Навигация -->
<nav class="bg-primary/90 backdrop-blur-md border-b border-gray-100 fixed w-full z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<span class="text-accent font-bold text-xl flex items-center">
<img src="https://static.photos/green/200x200/42" class="h-8 w-8 rounded-full mr-2" alt="Лого">
ЗемЭкспертAI
</span>
</div>
<div class="hidden md:flex items-center space-x-8">
<a href="index.html" class="text-gray-700 hover:text-secondary font-medium">Главная</a>
<a href="map.html" class="text-secondary font-medium">Карта</a>
<a href="catalog.html" class="text-gray-700 hover:text-secondary font-medium">Каталог</a>
<a href="#" class="text-gray-700 hover:text-secondary font-medium">Финансирование</a>
<a href="#" class="text-gray-700 hover:text-secondary font-medium">О нас</a>
</div>
<div class="flex items-center">
<button class="bg-secondary text-white px-4 py-2 rounded-md font-medium hover:bg-green-600 transition">
Войти
</button>
</div>
</div>
</div>
</nav>
<!-- Карта -->
<div id="map"></div>
<!-- Фильтры поверх карты -->
<div class="absolute top-24 left-4 z-10 bg-white p-4 rounded-lg shadow-lg">
<div class="space-y-4">
<div>
<label class="block text-gray-700 mb-1 text-sm font-medium">Категория</label>
<select id="category-filter" class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-secondary focus:border-transparent">
<option value="all">Все категории</option>
<option value="housing">Жилая застройка</option>
<option value="industry">Промышленность</option>
<option value="tourism">Туризм</option>
<option value="roadside">Придорожный сервис</option>
</select>
</div>
<div>
<label class="block text-gray-700 mb-1 text-sm font-medium">Бюджет, млн ₽</label>
<select id="price-filter" class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-secondary focus:border-transparent">
<option value="all">Любой</option>
<option value="0-50">До 50</option>
<option value="50-150">50-150</option>
<option value="150-300">150-300</option>
<option value="300+">300+</option>
</select>
</div>
<button id="apply-filters" class="w-full bg-secondary text-white py-2 rounded-md text-sm font-medium hover:bg-green-600 transition">
Применить
</button>
</div>
</div>
<script>
// Инициализация карты
ymaps.ready(init);
function init() {
const map = new ymaps.Map('map', {
center: [55.76, 37.64], // Москва
zoom: 10
});
// Примеры объектов (в реальном приложении получать через API)
const objects = [
{
id: 1,
name: 'Земельный участок в Подмосковье',
category: 'housing',
price: 125,
coordinates: [55.75, 37.62],
address: 'Московская обл., 30 км от МКАД',
image: 'https://static.photos/nature/200x200/1'
},
{
id: 2,
name: 'Промзона в Ленинградской обл.',
category: 'industry',
price: 85,
coordinates: [59.95, 30.30],
address: 'Ленинградская обл., 15 км от КАД',
image: 'https://static.photos/industry/200x200/2'
},
{
id: 3,
name: 'Земля на берегу Финского залива',
category: 'tourism',
price: 210,
coordinates: [60.10, 29.90],
address: 'Ленинградская обл., Курортный район',
image: 'https://static.photos/travel/200x200/3'
}
];
// Создание меток
objects.forEach(obj => {
const marker = new ymaps.Placemark(
obj.coordinates,
{
hintContent: obj.name,
balloonContent: `
<div class="marker-info">
<img src="${obj.image}" class="w-full h-32 object-cover rounded mb-2" alt="${obj.name}">
<h4 class="font-bold">${obj.name}</h4>
<p class="text-sm text-gray-600 mb-1">${obj.address}</p>
<p class="text-sm mb-2">Цена: <span class="font-bold">${obj.price} млн ₽</span></p>
<a href="project.html?id=${obj.id}" class="text-secondary text-sm font-medium hover:underline">Подробнее →</a>
</div>
`
},
{
preset: 'islands#greenDotIcon'
}
);
map.geoObjects.add(marker);
});
// Фильтрация объектов
document.getElementById('apply-filters').addEventListener('click', () => {
const category = document.getElementById('category-filter').value;
const priceRange = document.getElementById('price-filter').value;
map.geoObjects.removeAll();
objects.filter(obj => {
let match = true;
if (category !== 'all' && obj.category !== category) match = false;
if (priceRange !== 'all') {
const price = obj.price;
if (priceRange === '0-50' && price > 50) match = false;
if (priceRange === '50-150' && (price <= 50 || price > 150)) match = false;
if (priceRange === '150-300' && (price <= 150 || price > 300)) match = false;
if (priceRange === '300+' && price <= 300) match = false;
}
return match;
}).forEach(obj => {
const marker = new ymaps.Placemark(obj.coordinates, {
hintContent: obj.name,
balloonContent: `
<div class="marker-info">
<img src="${obj.image}" class="w-full h-32 object-cover rounded mb-2" alt="${obj.name}">
<h4 class="font-bold">${obj.name}</h4>
<p class="text-sm text-gray-600 mb-1">${obj.address}</p>
<p class="text-sm mb-2">Цена: <span class="font-bold">${obj.price} млн ₽</span></p>
<a href="project.html?id=${obj.id}" class="text-secondary text-sm font-medium hover:underline">Подробнее →</a>
</div>
`
}, {
preset: 'islands#greenDotIcon'
});
map.geoObjects.add(marker);
});
});
}
// Инициализация иконок
feather.replace();
</script>
</body>
</html>