Фикса
This commit is contained in:
parent
07198925d4
commit
5ebee78fec
@ -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)
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user