/
igormayer
/
openlayers-toolbox
Обзор
Документация
Войти
/
igormayer
/
openlayers-toolbox
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main.ts
54 строки
1 KB
Igor Mayer
fixes
01 мар 2026, 14:37
01 мар 2026, 14:37
048e344
Код
Авторство
О чём код?
import { Map, View } from 'ol'; import { fromLonLat } from 'ol/proj'; import { Legend } from './openlayers-toolbox'; import { LayerConfig } from './openlayers-toolbox'; // Создаем карту const map = new Map({ target: 'map', view: new View({ center: fromLonLat([30, 60]), zoom: 4 }) }); // Конфигурация слоев для примера const layerConfigs: LayerConfig[] = [ { id: 'osm_layer', title: 'OpenStreetMap', type: 'Tile', url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', position: 0, path: 'Base Maps' }, { id: 'ya_sattelite', title: 'Yandex sattelite', type: 'Tile', url: 'https://core-sat.maps.yandex.net/tiles?l=sat&v=3.2008.0&x={x}&y={y}&z={z}&scale=1&lang=ru_RU', position: 1, path: 'Yandex' }, { id: 'ya_map', title: 'Yandex map', type: 'Tile', url: 'https://core-renderer-tiles.maps.yandex.net/tiles?l=map&v=3.2008.0&x={x}&y={y}&z={z}&scale=1&lang=ru_RU', position: 2, path: 'Yandex' } ]; // Инициализируем легенду const legend = new Legend(map, { target: '#legend', className: 'ol-legend' }); // Добавляем слои legend.initialize(layerConfigs).then(() => { console.log('Legend initialized successfully'); }); export { map, legend };