122 lines
3.5 KiB
JavaScript
122 lines
3.5 KiB
JavaScript
const getGTOMarkerText = function (feature) {
|
|
const statemum = feature.get('garagenum')
|
|
if (statemum) {
|
|
return statemum;
|
|
}
|
|
return feature.get('name')
|
|
};
|
|
|
|
const createGTOStateNumTextStyle = function (feature, resolution) {
|
|
const font = 'bold' + ' ' + '12px' + '/' + '1' + ' ' + 'Arial';
|
|
return new ol.style.Text({
|
|
textAlign: 'center',
|
|
textBaseline: 'middle',
|
|
font: font,
|
|
text: getGTOMarkerText(feature, resolution),
|
|
fill: new ol.style.Fill({color: '#000'}),
|
|
offsetX: 0,
|
|
offsetY: -25,
|
|
placement: 'point',
|
|
maxAngle: '0.7853981633974483',
|
|
overflow: 'false',
|
|
rotation: parseFloat('0'),
|
|
backgroundFill: new ol.style.Fill({color: '#fff'}),
|
|
backgroundStroke: new ol.style.Stroke({color: '#000', width: 1}),
|
|
padding: [3, 3, 3, 3],
|
|
});
|
|
};
|
|
|
|
const createGTOZoneNameTextStyle = function (feature, resolution) {
|
|
const font = 'bold' + ' ' + '9px' + '/' + '1' + ' ' + 'Arial';
|
|
return new ol.style.Text({
|
|
textAlign: 'center',
|
|
textBaseline: 'middle',
|
|
font: font,
|
|
text: getGTOMarkerText(feature, resolution),
|
|
fill: new ol.style.Fill({color: '#000'}),
|
|
offsetX: 0,
|
|
offsetY: -25,
|
|
placement: 'point',
|
|
maxAngle: '0.7853981633974483',
|
|
overflow: 'false',
|
|
rotation: parseFloat('0'),
|
|
padding: [3, 3, 3, 3],
|
|
});
|
|
};
|
|
|
|
function GTOStyleFunction(feature, resolution) {
|
|
return new ol.style.Style({
|
|
image: new ol.style.Icon({
|
|
src: feature.get('icon') ? feature.get('icon') : "/static/img/belaz.png",
|
|
width: 30,
|
|
height: 20
|
|
}),
|
|
text: createGTOStateNumTextStyle(feature, resolution)
|
|
})
|
|
}
|
|
|
|
function createHatchPattern() {
|
|
// Создаем элемент canvas для шаблона штриховки
|
|
const canvas = document.createElement('canvas');
|
|
canvas.width = 10; // Ширина шаблона
|
|
canvas.height = 10; // Высота шаблона
|
|
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.strokeStyle = 'rgba(125, 105, 49, 0.1)'; // Цвет штриховки
|
|
ctx.lineWidth = 2;
|
|
|
|
// Рисуем диагональные линии для штриховки
|
|
ctx.beginPath();
|
|
ctx.moveTo(0, 10);
|
|
ctx.lineTo(10, 0);
|
|
ctx.stroke();
|
|
|
|
// Создаем паттерн из канваса
|
|
return ctx.createPattern(canvas, 'repeat');
|
|
}
|
|
|
|
function VlocationStyleFunction(feature, resolution) {
|
|
return new ol.style.Style({
|
|
image: new ol.style.Icon({
|
|
src: '/static/img/worker.png',
|
|
width: 25,
|
|
height: 30
|
|
})
|
|
})
|
|
}
|
|
|
|
function SPStyleFunction(feature, resolution) {
|
|
return new ol.style.Style({
|
|
image: new ol.style.Icon({
|
|
src: '/static/img/earthquake_yellow.png',
|
|
width: 25,
|
|
height: 30
|
|
})
|
|
})
|
|
}
|
|
|
|
function polygonStyleFunction(feature, resolution) {
|
|
return new ol.style.Style({
|
|
stroke: new ol.style.Stroke({
|
|
color: 'rgb(0,117,217)',
|
|
width: 2,
|
|
}),
|
|
fill: new ol.style.Fill({
|
|
color: createHatchPattern(),
|
|
}),
|
|
});
|
|
}
|
|
|
|
function polygonBrownStyleFunction(feature, resolution) {
|
|
return new ol.style.Style({
|
|
stroke: new ol.style.Stroke({
|
|
color: 'rgb(199,136,10)',
|
|
width: 2,
|
|
}),
|
|
fill: new ol.style.Fill({
|
|
color: 'rgba(199,136,10, 0.6)',
|
|
}),
|
|
text: createGTOZoneNameTextStyle(feature, resolution)
|
|
});
|
|
}
|