Изменение типов линий
This commit is contained in:
parent
923e1a247d
commit
bbda907a1d
@ -118,7 +118,7 @@
|
||||
<div class="row">
|
||||
<div class="col-5 col-sm-3">
|
||||
<div id="vert-tabs-tab"
|
||||
role="tablist" aria-orientation="vertical">
|
||||
role="tablist" aria-orientation="vertical" class="nav nav-pills">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-7 col-sm-9">
|
||||
@ -475,7 +475,7 @@
|
||||
const DEFAULT_STYLE = {
|
||||
"stroke-color": "#0000ff",
|
||||
"stroke-width": 2,
|
||||
{#'fill-color': "#fff"#}
|
||||
"stroke-line-dash": undefined
|
||||
};
|
||||
|
||||
// Функция для обновления стиля слоя
|
||||
@ -498,14 +498,37 @@
|
||||
vectorLayer.changed();
|
||||
}
|
||||
|
||||
function updateLayerStyleSelect(event) {
|
||||
const propertiesMap = {
|
||||
"solid": undefined,
|
||||
"dash-dot": [5, 2.5, 0, 2.5],
|
||||
"dot": [0, 2.5],
|
||||
}
|
||||
const input = event.target
|
||||
// Обновляем стиль для всех фич в слое
|
||||
vectorSource.getFeatures()
|
||||
.filter((feature) => feature.get('layer') === input.dataset.layer)
|
||||
.forEach((feature) => {
|
||||
const currentStyle = feature.get("style") || {};
|
||||
const property = input.id.split('_')[0];
|
||||
currentStyle[property] = propertiesMap[input.value];
|
||||
|
||||
// Устанавливаем обновленный стиль
|
||||
feature.set("style", currentStyle);
|
||||
});
|
||||
|
||||
// Обновляем слой
|
||||
vectorLayer.changed();
|
||||
}
|
||||
|
||||
function getLabelForProperty(property) {
|
||||
switch (property) {
|
||||
case "stroke-color":
|
||||
return "Цвет линии:"
|
||||
case "stroke-width":
|
||||
return "Ширина линии:"
|
||||
case "fill-color":
|
||||
return "Цвет заливки (Для замкнутых фигур)"
|
||||
case "stroke-line-dash":
|
||||
return "Тип линии:"
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,7 +553,6 @@
|
||||
tabLink.setAttribute('aria-controls', `layer_${layerName}`)
|
||||
tabLink.ariaSelected = 'false'
|
||||
tabLink.textContent = `Слой ${layerName}`
|
||||
|
||||
tabList.appendChild(tabLink)
|
||||
|
||||
|
||||
@ -572,13 +594,28 @@
|
||||
input.dataset.layer = layerName
|
||||
input.value = rgbToHex(style[property]) || DEFAULT_STYLE[property];
|
||||
input.className = "form-control";
|
||||
} else if (property === "fill-color") {
|
||||
input = document.createElement("input");
|
||||
input.type = "color";
|
||||
} else if (property === "stroke-line-dash") {
|
||||
input = document.createElement("select");
|
||||
input.id = `${property}_${layerName}`
|
||||
input.dataset.layer = layerName
|
||||
input.value = rgbToHex(style[property]) || DEFAULT_STYLE[property];
|
||||
input.className = "form-control";
|
||||
|
||||
const solid = document.createElement("option");
|
||||
solid.text = "Сплошная"
|
||||
solid.value = 'solid'
|
||||
|
||||
const dashDot = document.createElement("option");
|
||||
dashDot.text = "Штрихпунктирная"
|
||||
dashDot.value = 'dash-dot'
|
||||
|
||||
const dot = document.createElement("option");
|
||||
dot.text = "Пунктирная"
|
||||
dot.value = 'dot'
|
||||
|
||||
input.add(solid)
|
||||
input.add(dashDot)
|
||||
input.add(dot)
|
||||
|
||||
}
|
||||
|
||||
col.appendChild(label);
|
||||
@ -591,7 +628,12 @@
|
||||
|
||||
// Добавляем обработчики событий для полей ввода
|
||||
tabContent.querySelectorAll("input").forEach((input) => {
|
||||
input.addEventListener("input", updateLayerStyle);
|
||||
if (input.type === "color" || input.type === "number") {
|
||||
input.addEventListener("input", updateLayerStyle);
|
||||
}
|
||||
});
|
||||
tabContent.querySelectorAll("select").forEach((select) => {
|
||||
select.addEventListener("input", updateLayerStyleSelect);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user