сделай так чтобы границы вокруг Кыргызстана были прозрачными наполовину и сделай так…
- User
сделай так чтобы границы вокруг Кыргызстана были прозрачными наполовину и сделай так чтобы поверхность самого Кыргызстана не была затенена
import React, { useState } from 'react'; import { MapContainer, TileLayer, GeoJSON } from 'react-leaflet'; import 'leaflet/dist/leaflet.css'; import './KyrgyzstanMap.scss'; import Button from '../Button/Button';
import kyrgyzstanData from '../data/kyrgyzstan.json'; import worldData from '../data/world.json'; // Убедитесь, что этот файл существует
const KyrgyzstanMap = () => { const [is3D, setIs3D] = useState(false); const [currentStyle, setCurrentStyle] = useState('streets');
const bounds = [ [34, 64], [48, 85], ];
const center = [41.2044, 74.7661]; const minZoom = 5; const maxZoom = 15;
const handleToggle3D = () => { setIs3D(prev => !prev); alert('3D режим не поддерживается в Leaflet по умолчанию.'); };
const handleChangeStyle = (styleId) => { setCurrentStyle(styleId); };
const styleMap = { streets: { url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', attribution: '© OpenStreetMap contributors', }, satellite: { url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', attribution: '© OpenTopoMap', }, light: { url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', attribution: '© CARTO', }, dark: { url: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', attribution: '© CARTO', }, outdoors: { url: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', attribution: '© OpenStreetMap contributors, Tiles style by HOT', }, 'satellite-streets': { url: 'https://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png', attribution: '© Stamen Design', }, };
const otherCountriesStyle = { fillColor: 'grey', weight: 1, color: '#666', fillOpacity: 0.5, };
const kyrgyzstanStyle = { fillOpacity: 0, weight: 3, color: '#FF0000', };
const onEachCountry = (country, layer) => { if (country.properties.ADMIN === "Kyrgyzstan") { layer.bindPopup("Кыргызстан"); } };
return ( <button className={toggle-button ${is3D ? 'active' : ''}} onClick={handleToggle3D} > {is3D ? 'Переключить на 2D' : 'Переключить на 3D'}
<div className="style-buttons"> <Button onClick={() => handleChangeStyle('streets')} variant="outline"> Улицы </Button> <Button onClick={() => handleChangeStyle('satellite')} variant="outline"> Спутник </Button> <Button onClick={() => handleChangeStyle('light')} variant="outline"> Светлый </Button> <Button onClick={() => handleChangeStyle('dark')} variant="outline"> Темный </Button> <Button onClick={() => handleChangeStyle('outdoors')} variant="outline"> На открытом воздухе </Button> <Button onClick={() => handleChangeStyle('satellite-streets')} variant="outline"> Спутник+Улицы </Button> </div> </div> <MapContainer center={center} zoom={7} minZoom={minZoom} maxZoom={maxZoom} maxBounds={bounds} style={{ height: '100vh', width: '100%' }} scrollWheelZoom={true} > <TileLayer url={styleMap[currentStyle].url} attribution={styleMap[currentStyle].attribution} /> {/* Затенение остальных стран */} <GeoJSON data={worldData} style={otherCountriesStyle} /> {/* Выделение Кыргызстана */} <GeoJSON data={kyrgyzstanData} style={kyrgyzstanStyle} onEachFeature={onEachCountry} /> </MapContainer> </div> - Assistant