diff --git a/positioning/apps/eps/templates/eps/report/street_history.html b/positioning/apps/eps/templates/eps/report/street_history.html
index 37d54e0..e0c0c75 100644
--- a/positioning/apps/eps/templates/eps/report/street_history.html
+++ b/positioning/apps/eps/templates/eps/report/street_history.html
@@ -197,90 +197,100 @@
mapCore.addLayer(historyLayer, 'static');
- function getColorByColorIndex(colorIndex) {
- const colors = ["#0d6efd", "#6f42c1", "#dc3545", "#fd7e14", "#d63384", "#ffc107", "#198754", "#20c997", "#0dcaf0", "#6610f2"]
- let numIndex = Number(colorIndex)
- while (colorIndex > colors.length) numIndex -= colors.length
- return colors[numIndex]
- }
+function getColorByColorIndex(colorIndex) {
+ const colors = ["#0d6efd", "#6f42c1", "#dc3545", "#fd7e14", "#d63384",
+ "#ffc107", "#198754", "#20c997", "#0dcaf0", "#6610f2"];
+ let numIndex = Number(colorIndex);
+ while (numIndex >= colors.length) numIndex -= colors.length;
+ return colors[numIndex];
+}
- function styleFunction(feature) {
- const geometry = feature.getGeometry();
- const styles = [];
- const colorIndex = feature.get('colorIndex')
- const fillColor = getColorByColorIndex(colorIndex)
- console.log(fillColor)
- if (geometry.getType() === 'LineString') {
- // Стилизация линии
- styles.push(
- new ol.style.Style({
- stroke: new ol.style.Stroke({
- color: fillColor,
- width: 2,
- }),
- })
- );
+function styleFunction(feature) {
+ const geometry = feature.getGeometry();
+ const styles = [];
+ const colorIndex = feature.get('colorIndex');
+ const fillColor = getColorByColorIndex(colorIndex);
- geometry.forEachSegment(function (start, end) {
- const dx = end[0] - start[0];
- const dy = end[1] - start[1];
- const rotation = Math.atan2(dy, dx);
- var svg = ``;
- // Стрелочки на концах линий
- styles.push(
- new ol.style.Style({
- geometry: new ol.geom.Point(end),
- image: new ol.style.Icon({
- src: 'data:image/svg+xml;utf8,' + svg,
- anchor: [0.9, 0.5],
- rotateWithView: true,
- rotation: -rotation,
- }),
- })
- );
- });
+ if (geometry.getType() === 'LineString') {
+ // Стиль для линии
+ styles.push(
+ new ol.style.Style({
+ stroke: new ol.style.Stroke({
+ color: fillColor,
+ width: 2,
+ }),
+ })
+ );
- styles.push(
- new ol.style.Style({
- text: new ol.style.Text({
- text: feature.get("name"),
- font: '12px Calibri,sans-serif',
- fill: new ol.style.Fill({color: '#000'}),
- stroke: new ol.style.Stroke({color: '#fff', width: 2}),
- placement: 'line',
- }),
- })
- );
+ geometry.forEachSegment(function(start, end) {
+ const dx = end[0] - start[0];
+ const dy = end[1] - start[1];
+ const rotation = Math.atan2(dy, dx);
- } else if (geometry.getType() === 'Point') {
- // Стилизация точки
- styles.push(
- new ol.style.Style({
- image: new ol.style.Circle({
- radius: 5,
- fill: new ol.style.Fill({color: 'white'}),
- stroke: new ol.style.Stroke({color: `${fillColor}`, width: 1}),
- }),
- })
- );
+ // Динамически создаём SVG с нужным цветом
+ const svg = ``;
- if (time) {
- styles.push(
- new ol.style.Style({
- text: new ol.style.Text({
- text: feature.get('time'),
- font: '12px Calibri,sans-serif',
- fill: new ol.style.Fill({color: '#000'}),
- stroke: new ol.style.Stroke({color: '#fff', width: 2}),
- offsetY: -15, // Чуть выше точки
- }),
- })
- );
- }
- }
+ // Правильно кодируем SVG для data URI
+ const encodedSvg = encodeURIComponent(svg);
- return styles;
- }
+ styles.push(
+ new ol.style.Style({
+ geometry: new ol.geom.Point(end),
+ image: new ol.style.Icon({
+ src: 'data:image/svg+xml;utf8,' + encodedSvg,
+ anchor: [0.9, 0.5],
+ rotateWithView: true,
+ rotation: -rotation,
+ scale: 0.8 // Можно добавить масштаб при необходимости
+ }),
+ })
+ );
+ });
+
+ // Стиль для текста
+ styles.push(
+ new ol.style.Style({
+ text: new ol.style.Text({
+ text: feature.get("name"),
+ font: '12px Calibri,sans-serif',
+ fill: new ol.style.Fill({color: '#000'}),
+ stroke: new ol.style.Stroke({color: '#fff', width: 2}),
+ placement: 'line',
+ }),
+ })
+ );
+ }
+ else if (geometry.getType() === 'Point') {
+ // Стиль для точки
+ styles.push(
+ new ol.style.Style({
+ image: new ol.style.Circle({
+ radius: 5,
+ fill: new ol.style.Fill({color: 'white'}),
+ stroke: new ol.style.Stroke({color: fillColor, width: 1}),
+ }),
+ })
+ );
+
+ if (feature.get('time')) {
+ styles.push(
+ new ol.style.Style({
+ text: new ol.style.Text({
+ text: feature.get('time'),
+ font: '12px Calibri,sans-serif',
+ fill: new ol.style.Fill({color: '#000'}),
+ stroke: new ol.style.Stroke({color: '#fff', width: 2}),
+ offsetY: -15,
+ }),
+ })
+ );
+ }
+ }
+
+ return styles;
+}
function polygonGrayStyleFunction(feature, resolution) {
diff --git a/static/openLayers/map/map-core.js b/static/openLayers/map/map-core.js
index af3fadc..5e180fb 100644
--- a/static/openLayers/map/map-core.js
+++ b/static/openLayers/map/map-core.js
@@ -17,6 +17,7 @@ const propertiesTranslate = {
uid: "Идентификатор",
description: "Описание"
}
+const invisibleProperties = ['id', 'geometry', 'icon', 'condition', 'style', 'layer', 'pk', "colorIndex"]
let popover;
function disposePopover() {
@@ -134,7 +135,6 @@ class MapCore {
function createPopover(feature) {
const res = document.createElement('div')
const properties = feature.getProperties()
- const invisibleProperties = ['id', 'geometry', 'icon', 'condition', 'style', 'layer', 'pk']
for (let property in properties) {
if (invisibleProperties.includes(property)) continue
let div = document.createElement('div')