From 5eef73eb3b13fa2c0b9de314d0aaa464c87a5500 Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Wed, 15 Jan 2025 14:04:31 +0700 Subject: [PATCH] =?UTF-8?q?=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BB=D0=BE=D0=B5=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/main/templates/main_index.html | 25 +++++++++++++++++-------- apps/main/views/views_main.py | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html index efa9838..29ee218 100644 --- a/apps/main/templates/main_index.html +++ b/apps/main/templates/main_index.html @@ -340,8 +340,24 @@ 'EPSG:3857' // Целевая проекция ) }); + + scanLayer.set('name', 'Ортофотоплан') + const layers = [ + OSM, + mineBorderLayer, + SPLayer, + VlocationLayer, + GTOLayer, + ] + + const scanLayerExists = Boolean(parseInt('{{ scan_layer_enable }}')) + + if (scanLayerExists) { + layers.splice(1, 0, scanLayer) + } + // Создание карты map = new ol.Map({ target: 'map', // ID элемента, куда встроится карта @@ -350,14 +366,7 @@ new ol.control.ScaleLine(), new ol.control.ZoomSlider() ], - layers: [ - OSM, - {#scanLayer,#} - mineBorderLayer, - SPLayer, - VlocationLayer, - GTOLayer, - ], + layers: layers, view: new ol.View({ center: ol.proj.fromLonLat([centerLat, centerLon]), // Центр карты zoom: 12, diff --git a/apps/main/views/views_main.py b/apps/main/views/views_main.py index 179a040..a0e5a6a 100644 --- a/apps/main/views/views_main.py +++ b/apps/main/views/views_main.py @@ -30,12 +30,13 @@ def mainindex(request): lat = str(float(settingsmodule.get_settings('latitude', '55.344251210827814'))) # широта kml_path = settingsmodule.get_settings('kml_path', '') - + scan_layer_enable = settingsmodule.get_settings('scan_layer_enable', '0') context = generalmodule.get_context_template() context.update({ 'lon': lon.replace(',', '.'), 'lat': lat.replace(',', '.'), 'kml_path': kml_path, + 'scan_layer_enable': scan_layer_enable, 'updatepage': True, }) return render(request, 'main_index.html', context)