fix баги с выделением
This commit is contained in:
parent
a628809b22
commit
58458748bc
@ -119,6 +119,8 @@
|
||||
<script>
|
||||
let centerLat = parseFloat('{{lat}}')
|
||||
let centerLon = parseFloat('{{lon}}')
|
||||
let transformInteraction = {}
|
||||
let translateInteraction = {}
|
||||
console.log(centerLat)
|
||||
let i = 0
|
||||
scanLayer = new ol.layer.Tile({
|
||||
@ -153,6 +155,15 @@
|
||||
zoom: 12,
|
||||
})
|
||||
});
|
||||
translateInteraction = new ol.interaction.Translate({
|
||||
});
|
||||
map.addInteraction(translateInteraction);
|
||||
|
||||
// Добавляем возможность масштабирования и перемещения с помощью маркеров
|
||||
transformInteraction = new ol.interaction.Transform({
|
||||
addCondition: ol.events.condition.shiftKeyOnly
|
||||
});
|
||||
map.addInteraction(transformInteraction);
|
||||
let vectorLayer;
|
||||
document.getElementById('id_layer_file_input').addEventListener('change', function (event) {
|
||||
const file = event.target.files[0];
|
||||
@ -163,6 +174,7 @@
|
||||
try {
|
||||
const dxf = parser.parseSync(e.target.result);
|
||||
const geojson = dxfToGeoJSON(dxf);
|
||||
clearVectorLayer()
|
||||
addGeoJSONToMap(geojson);
|
||||
} catch (error) {
|
||||
console.error('DXF Parsing Error:', error);
|
||||
@ -288,17 +300,7 @@
|
||||
map.addLayer(vectorLayer);
|
||||
const group = new ol.Collection(vectorSource.getFeatures());
|
||||
// Добавляем возможность перетаскивания
|
||||
const translateInteraction = new ol.interaction.Translate({
|
||||
features: group,
|
||||
});
|
||||
map.addInteraction(translateInteraction);
|
||||
|
||||
// Добавляем возможность масштабирования и перемещения с помощью маркеров
|
||||
const transformInteraction = new ol.interaction.Transform({
|
||||
features: group,
|
||||
addCondition: ol.events.condition.shiftKeyOnly
|
||||
});
|
||||
map.addInteraction(transformInteraction);
|
||||
|
||||
// Выделение всех фичей
|
||||
transformInteraction.setSelection(group)
|
||||
@ -321,9 +323,7 @@
|
||||
const kx = 1.676;
|
||||
const ky = 1.001;
|
||||
|
||||
console.log(`Координаты до конвертации [${x},${y}]`)
|
||||
res = ol.proj.transform([x, y], 'EPSG:3857', 'EPSG:4326')
|
||||
console.log(`Координаты после конвертации [${res[0]},${res[1]}]`)
|
||||
let res = ol.proj.transform([x, y], 'EPSG:3857', 'EPSG:4326')
|
||||
res[0] = kx * res[0] + 87.915936 // ДОЛГОТА
|
||||
res[1] = ky * res[1] + 53.688360 // ШИРОТА
|
||||
return res;
|
||||
@ -377,5 +377,14 @@
|
||||
}
|
||||
});
|
||||
|
||||
function clearVectorLayer() {
|
||||
if (vectorLayer) {
|
||||
// Удаляем векторный слой с карты
|
||||
map.removeLayer(vectorLayer);
|
||||
vectorLayer = null;
|
||||
}
|
||||
const emptyGroup = new ol.Collection();
|
||||
transformInteraction.setSelection(emptyGroup)
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user