From f4b17a2f2572acf09ddda0c644565eace00c18a5 Mon Sep 17 00:00:00 2001
From: zakhy <=>
Date: Tue, 14 Jan 2025 09:55:38 +0700
Subject: [PATCH 1/2] =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?=
=?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?=
=?UTF-8?q?=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
apps/main/templates/main_index.html | 94 +++++++++++++++--------------
1 file changed, 48 insertions(+), 46 deletions(-)
diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html
index 9625ec2..d44bc35 100644
--- a/apps/main/templates/main_index.html
+++ b/apps/main/templates/main_index.html
@@ -66,6 +66,9 @@
let mineBorderLayer = {}
+ let scanSource = {}
+ let scanLayer = {}
+
let centerLat = '{{lon}}'
let centerLon = '{{lat}}'
@@ -189,50 +192,7 @@
requestAnimationFrame(animate);
}
-
- function initializeMap() {
- OSM = new ol.layer.Tile({
- source: new ol.source.OSM(), // Open street Map
- })
- OSM.set('name', 'OpenStreet Map')
- // Источник данных для GTO
- GTOSource = new ol.source.Vector();
-
- // Слой для отображения GTO
- GTOLayer = new ol.layer.Vector({
- source: GTOSource,
- style: GTOStyleFunction
- });
- GTOLayer.set('name', 'Горнотранспортное оборудование')
-
- // Источник данных для Vlocation
- VlocationSource = new ol.source.Vector();
-
- // Слой для Vlocation
- VlocationLayer = new ol.layer.Vector({
- source: VlocationSource,
- style: VlocationStyleFunction
- })
- VlocationLayer.set('name', 'Местоположение сотрудников')
-
- SPSource = new ol.source.Vector();
- SPLayer = new ol.layer.Vector({
- source: SPSource,
- style: SPStyleFunction
- });
- SPLayer.set('name', 'Сейсмические процессы')
-
- mineBorderLayer = new ol.layer.Vector({
- source: new ol.source.Vector({
- url: '/static/border.kml/',
- format: new ol.format.KML({extractStyles: false}),
-
- }),
- style: polygonStyleFunction,
- });
- mineBorderLayer.set('name', 'Границы ПРГР')
-
- class LayerSwitcherControl extends ol.control.Control {
+ class LayerSwitcherControl extends ol.control.Control {
/**
* @param {Object} [opt_options] Control options.
*/
@@ -325,6 +285,48 @@
}
}
+ function initializeMap() {
+ OSM = new ol.layer.Tile({
+ source: new ol.source.OSM(), // Open street Map
+ })
+ OSM.set('name', 'OpenStreet Map')
+ // Источник данных для GTO
+ GTOSource = new ol.source.Vector();
+
+ // Слой для отображения GTO
+ GTOLayer = new ol.layer.Vector({
+ source: GTOSource,
+ style: GTOStyleFunction
+ });
+ GTOLayer.set('name', 'Горнотранспортное оборудование')
+
+ // Источник данных для Vlocation
+ VlocationSource = new ol.source.Vector();
+
+ // Слой для Vlocation
+ VlocationLayer = new ol.layer.Vector({
+ source: VlocationSource,
+ style: VlocationStyleFunction
+ })
+ VlocationLayer.set('name', 'Местоположение сотрудников')
+
+ SPSource = new ol.source.Vector();
+ SPLayer = new ol.layer.Vector({
+ source: SPSource,
+ style: SPStyleFunction
+ });
+ SPLayer.set('name', 'Сейсмические процессы')
+
+ mineBorderLayer = new ol.layer.Vector({
+ source: new ol.source.Vector({
+ url: '/static/border.kml/',
+ format: new ol.format.KML({extractStyles: false}),
+
+ }),
+ style: polygonStyleFunction,
+ });
+ mineBorderLayer.set('name', 'Границы ПРГР')
+
// Создание карты
map = new ol.Map({
@@ -460,7 +462,7 @@
strong.textContent = "Глубина: "
div.appendChild(strong)
- span.textContent = feature.get('depth')
+ span.textContent = feature.get('depth') + " км."
div.appendChild(span)
res.appendChild(div)
@@ -474,7 +476,7 @@
strong.textContent = "Магнитуда: "
div.appendChild(strong)
- span.textContent = feature.get('magnitude') + " км."
+ span.textContent = feature.get('magnitude')
div.appendChild(span)
res.appendChild(div)
From 5efc728f70c7c54f79b5a71934700b97af014f68 Mon Sep 17 00:00:00 2001
From: zakhy <=>
Date: Tue, 14 Jan 2025 11:53:45 +0700
Subject: [PATCH 2/2] fix
---
apps/main/templates/main_index.html | 186 +++++++++++++++-------------
1 file changed, 102 insertions(+), 84 deletions(-)
diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html
index d44bc35..f64f388 100644
--- a/apps/main/templates/main_index.html
+++ b/apps/main/templates/main_index.html
@@ -21,6 +21,7 @@
right: 10px; /* Отступ от правой границы */
z-index: 1000;
}
+
.ol-layer-list {
list-style: none;
}
@@ -34,7 +35,10 @@
-
+
@@ -193,98 +197,98 @@
}
class LayerSwitcherControl extends ol.control.Control {
- /**
- * @param {Object} [opt_options] Control options.
- */
- constructor(opt_options) {
- const options = opt_options || {};
+ /**
+ * @param {Object} [opt_options] Control options.
+ */
+ constructor(opt_options) {
+ const options = opt_options || {};
- // Создание кнопки для переключателя слоёв
- const button = document.createElement('button');
- button.innerHTML = ``; // Иконка для кнопки
+ // Создание кнопки для переключателя слоёв
+ const button = document.createElement('button');
+ button.innerHTML = ``; // Иконка для кнопки
- // Создание контейнера для контрола
- const element = document.createElement('div');
- element.className = 'layer-switcher ol-unselectable ol-control layer-switcher-bottom-right'; // Добавляем класс для позиционирования
- element.appendChild(button);
+ // Создание контейнера для контрола
+ const element = document.createElement('div');
+ element.className = 'layer-switcher ol-unselectable ol-control layer-switcher-bottom-right'; // Добавляем класс для позиционирования
+ element.appendChild(button);
- super({
- element: element,
- target: options.target,
- });
+ super({
+ element: element,
+ target: options.target,
+ });
- // Слушатель нажатия на кнопку
- button.addEventListener('click', this.toggleLayerList.bind(this), false);
+ // Слушатель нажатия на кнопку
+ button.addEventListener('click', this.toggleLayerList.bind(this), false);
- // Список слоёв (скрытый по умолчанию)
- this.layerList = document.createElement('ul');
- this.layerList.className = 'ol-layer-list';
+ // Список слоёв (скрытый по умолчанию)
+ this.layerList = document.createElement('ul');
+ this.layerList.className = 'ol-layer-list';
+ this.layerList.style.display = 'none';
+ element.appendChild(this.layerList);
+
+ // Подключаем событие для обновления списка слоёв после инициализации карты
+ this.onMapLoaded();
+ }
+
+ /**
+ * Переключение видимости списка слоёв
+ */
+ toggleLayerList() {
+ if (this.layerList.style.display === 'block') {
this.layerList.style.display = 'none';
- element.appendChild(this.layerList);
-
- // Подключаем событие для обновления списка слоёв после инициализации карты
- this.onMapLoaded();
- }
-
- /**
- * Переключение видимости списка слоёв
- */
- toggleLayerList() {
- if (this.layerList.style.display === 'block') {
- this.layerList.style.display = 'none';
- } else {
- this.layerList.style.display = 'block';
- }
- }
-
- /**
- * Обновление списка слоёв в контроле
- */
- updateLayerList() {
- const map = this.getMap();
- if (!map) {
- return;
- }
-
- const layers = map.getLayers().getArray();
-
- // Очищаем старый список
- this.layerList.innerHTML = '';
-
- layers.forEach((layer) => {
- const layerItem = document.createElement('li');
- const checkbox = document.createElement('input');
- checkbox.type = 'checkbox';
- checkbox.checked = layer.getVisible(); // Задаем состояние видимости слоя
- checkbox.addEventListener('click', () => {
- layer.setVisible(checkbox.checked); // Изменение видимости слоя
- });
- const label = document.createElement('label');
- label.innerHTML = layer.get('name') || 'Unnamed Layer'; // Отображение названия слоя
- layerItem.appendChild(checkbox);
- layerItem.appendChild(label);
- this.layerList.appendChild(layerItem);
- });
- }
-
- /**
- * Ожидаем, когда карта будет инициализирована, и обновим список слоёв
- */
- onMapLoaded() {
- const map = this.getMap();
- if (map) {
- this.updateLayerList();
- // Подписываемся на изменения слоёв
- map.on('change:layers', () => {
- this.updateLayerList();
- });
- } else {
- // В случае, если карта еще не инициализирована, используем setTimeout
- setTimeout(this.onMapLoaded.bind(this), 100);
- }
+ } else {
+ this.layerList.style.display = 'block';
}
}
+ /**
+ * Обновление списка слоёв в контроле
+ */
+ updateLayerList() {
+ const map = this.getMap();
+ if (!map) {
+ return;
+ }
+
+ const layers = map.getLayers().getArray();
+
+ // Очищаем старый список
+ this.layerList.innerHTML = '';
+
+ layers.forEach((layer) => {
+ const layerItem = document.createElement('li');
+ const checkbox = document.createElement('input');
+ checkbox.type = 'checkbox';
+ checkbox.checked = layer.getVisible(); // Задаем состояние видимости слоя
+ checkbox.addEventListener('click', () => {
+ layer.setVisible(checkbox.checked); // Изменение видимости слоя
+ });
+ const label = document.createElement('label');
+ label.innerHTML = layer.get('name') || 'Unnamed Layer'; // Отображение названия слоя
+ layerItem.appendChild(checkbox);
+ layerItem.appendChild(label);
+ this.layerList.appendChild(layerItem);
+ });
+ }
+
+ /**
+ * Ожидаем, когда карта будет инициализирована, и обновим список слоёв
+ */
+ onMapLoaded() {
+ const map = this.getMap();
+ if (map) {
+ this.updateLayerList();
+ // Подписываемся на изменения слоёв
+ map.on('change:layers', () => {
+ this.updateLayerList();
+ });
+ } else {
+ // В случае, если карта еще не инициализирована, используем setTimeout
+ setTimeout(this.onMapLoaded.bind(this), 100);
+ }
+ }
+ }
+
function initializeMap() {
OSM = new ol.layer.Tile({
source: new ol.source.OSM(), // Open street Map
@@ -327,7 +331,20 @@
});
mineBorderLayer.set('name', 'Границы ПРГР')
+ // const imageExtent = ol.proj.transformExtent(
+ // [86.639393, 53.959368, 86.698046, 54.004628], // [minLon, minLat, maxLon, maxLat]
+ // 'EPSG:4326', // Исходная проекция
+ // 'EPSG:3857' // Целевая проекция
+ // );
+ // const scanSource = new ol.source.ImageStatic({
+ // url: '/static/img/mine.png',
+ // imageExtent: imageExtent // Преобразованные координаты
+ // });
+
+ // const scanLayer = new ol.layer.Image({
+ // source: scanSource
+ // });
// Создание карты
map = new ol.Map({
target: 'map', // ID элемента, куда встроится карта
@@ -340,6 +357,7 @@
],
layers: [
OSM,
+ // scanLayer,
mineBorderLayer,
GTOLayer,
SPLayer,