From 5ebee78fec67c7567adfbf23122756602b4adcfa Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Wed, 14 May 2025 15:22:40 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/form_orthomosaic.html | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/apps/management/templates/form_orthomosaic.html b/apps/management/templates/form_orthomosaic.html index 49a8321..c02f2b2 100644 --- a/apps/management/templates/form_orthomosaic.html +++ b/apps/management/templates/form_orthomosaic.html @@ -289,25 +289,14 @@ parseFloat('{{ form.instance.max_lon|safe }}'), parseFloat('{{ form.instance.max_lat|safe }}') ], - 'EPSG:4326', - 'EPSG:3857' + 'EPSG:4326', // Исходная проекция + 'EPSG:3857' // Целевая проекция ); - - const padding = 20; - const paddedExtent = ol.extent.buffer(extent, padding); - const mapCore = new MapCore('map', { center: ['{{longitude}}', '{{latitude}}'], - zoom: 12, - view: new ol.View({ - extent: paddedExtent, - constrainOnlyCenter: false, - multiWorld: false - }) + zoom: 12 }); - await mapCore.initialize(); - const scanLayer = new ol.layer.Tile({ source: new ol.source.XYZ({ url: `{{ form.instance.url }}`, @@ -318,6 +307,7 @@ scanLayer.set('name', 'orto') mapCore.addLayer(scanLayer) + mapCore.map.getView().fit(extent, { padding: [20, 20, 20, 20], duration: 1000, @@ -325,6 +315,7 @@ }); const extentPolygon = ol.geom.Polygon.fromExtent(extent); + const vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({ features: [ @@ -340,20 +331,7 @@ }), }), }); - mapCore.addLayer(vectorLayer); - - mapCore.map.getView().on('change:center', () => { - const view = mapCore.map.getView(); - const currentCenter = view.getCenter(); - const currentExtent = view.calculateExtent(mapCore.map.getSize()); - - if (!ol.extent.containsExtent(paddedExtent, currentExtent)) { - view.setCenter([ - Math.max(paddedExtent[0], Math.min(paddedExtent[2], currentCenter[0])), - Math.max(paddedExtent[1], Math.min(paddedExtent[3], currentCenter[1])) - ]); - } - }); + mapCore.addLayer(vectorLayer) });