Перенес стили в один файл

This commit is contained in:
zakhy 2025-05-19 09:42:29 +07:00
parent b343fd85cc
commit 74703e9c1d
3 changed files with 73 additions and 32 deletions

View File

@ -48,6 +48,7 @@
<script src="{% static '/openLayers/map/map-layer-switcher.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/map/map-marker-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/map/map-created-layer-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/layersStyles.js' %}?ver={% settings_value 'APP_VER' %}"></script>
{% endblock %}
{% block script_footer %}
@ -161,25 +162,7 @@
await updateMarkers();
setInterval(updateMarkers, 3000);
function VlocationStyleFunction(feature, resolution) {
return new ol.style.Style({
image: new ol.style.Icon({
src: '{% static 'img/worker.png' %}',
width: 25,
height: 30
})
})
}
function BaseStationStyleFunction(feature, resolution) {
return new ol.style.Style({
image: new ol.style.Icon({
src: '{% static 'img/base-station.png' %}',
width: 50,
height: 40
})
})
}
function polygonGrayStyleFunction(feature, resolution) {
return new ol.style.Style({

View File

@ -65,6 +65,7 @@
<script src="{% static '/openLayers/map/map-layer-switcher.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/map/map-marker-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/map/map-created-layer-manager.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<script src="{% static '/openLayers/layersStyles.js' %}?ver={% settings_value 'APP_VER' %}"></script>
{% endblock %}
{% block script_footer %}
<script>
@ -183,16 +184,6 @@
tr.appendChild(tdWorkerCoord)
return tr
}
function VlocationStyleFunction(feature, resolution) {
return new ol.style.Style({
image: new ol.style.Icon({
src: '/static/img/worker.png',
width: 25,
height: 30
})
})
}
});
</script>

View File

@ -75,16 +75,83 @@ function createHatchPattern() {
return ctx.createPattern(canvas, 'repeat');
}
function VlocationStyleFunction(feature, resolution) {
function BaseStationStyleFunction(feature, resolution) {
return new ol.style.Style({
image: new ol.style.Icon({
src: '/static/img/worker.png',
width: 25,
height: 30
src: '/static/img/base-station.png',
width: 50,
height: 40
})
})
}
const createFeatureTextStyle = function (feature, resolution, bgFill, textFill) {
const font = 'bold' + ' ' + '12px' + '/' + '1' + ' ' + 'Arial';
return new ol.style.Text({
textAlign: 'center',
textBaseline: 'middle',
font: font,
text: feature.get('sn'),
fill: textFill,
offsetX: 0,
offsetY: -27,
placement: 'point',
maxAngle: '0.7853981633974483',
overflow: 'false',
rotation: parseFloat('0'),
backgroundFill: bgFill,
backgroundStroke: new ol.style.Stroke({color: '#000', width: 1}),
padding: [3, 3, 3, 3],
});
};
function VlocationStyleFunction(feature, resolution) {
const objDate = new Date(feature.get("iso_time"))
let bgFill = undefined
let textFill = new ol.style.Fill({color: '#000'})
if (objDate) {
const nowDate = new Date()
const diffDate = (nowDate - objDate) / (1000 * 60 * 60)
if (diffDate < 1) {
bgFill = '#fff'
} else if (diffDate > 1 && diffDate < 24) {
bgFill = '#ffc107'
} else {
bgFill = "#bebebe"
}
}
const backgroundStyle = new ol.style.Circle({
radius: 15,
fill: new ol.style.Fill({
color: bgFill
}),
stroke: new ol.style.Stroke({
color: '#000',
width: 1
})
});
return [
new ol.style.Style({
image: backgroundStyle
}),
new ol.style.Style({
image: new ol.style.Icon({
src: '/static/img/worker.png',
width: 25,
height: 30
})
}),
new ol.style.Style({
text: createFeatureTextStyle(feature, resolution, new ol.style.Fill({color: bgFill}), textFill)
})
];
}
function SPStyleFunction(feature, resolution) {
return new ol.style.Style({
image: new ol.style.Icon({