Обновление свойств маркера в динамике
This commit is contained in:
parent
353e280c05
commit
b324556fca
@ -720,6 +720,9 @@
|
||||
data.forEach(equipment => {
|
||||
if (GTOMarkers[equipment.id]) {
|
||||
const marker = GTOMarkers[equipment.id];
|
||||
|
||||
updateMarkerProperties(marker, equipment)
|
||||
|
||||
const currentCoordinates = marker.getGeometry().getCoordinates();
|
||||
const newCoordinates = ol.proj.fromLonLat([equipment.lon, equipment.lat]);
|
||||
|
||||
@ -745,6 +748,12 @@
|
||||
|
||||
window.onload = initializeMap;
|
||||
|
||||
|
||||
function updateMarkerProperties(marker, properties) {
|
||||
for (let property in properties) {
|
||||
marker.set(property, properties[property])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock script_footer %}
|
||||
|
||||
@ -523,21 +523,21 @@
|
||||
}
|
||||
layersBtn.classList.toggle("selected")
|
||||
})
|
||||
layerSwitcher.addControl(
|
||||
new ol.control.Button({
|
||||
html: "Создать слой",
|
||||
handleClick: function () {
|
||||
window.location.href = '{% url 'create_layer' %}'
|
||||
}
|
||||
}), 'bottom');
|
||||
layerSwitcher.addControl(
|
||||
new ol.control.Button({
|
||||
html: "Редактировать слои",
|
||||
handleClick: function () {
|
||||
window.location.href = '{% url 'layers_list' %}'
|
||||
}
|
||||
}), 'bottom'
|
||||
);
|
||||
layerSwitcher.addControl(
|
||||
new ol.control.Button({
|
||||
html: "Создать слой",
|
||||
handleClick: function () {
|
||||
window.location.href = '{% url 'create_layer' %}'
|
||||
}
|
||||
}), 'bottom');
|
||||
layerSwitcher.addControl(
|
||||
new ol.control.Button({
|
||||
html: "Редактировать слои",
|
||||
handleClick: function () {
|
||||
window.location.href = '{% url 'layers_list' %}'
|
||||
}
|
||||
}), 'bottom'
|
||||
);
|
||||
|
||||
map.addControl(layerSwitcher)
|
||||
|
||||
@ -801,6 +801,9 @@
|
||||
data.forEach(equipment => {
|
||||
if (GTOMarkers[equipment.id]) {
|
||||
const marker = GTOMarkers[equipment.id];
|
||||
|
||||
updateMarkerProperties(marker, equipment)
|
||||
|
||||
const currentCoordinates = marker.getGeometry().getCoordinates();
|
||||
const newCoordinates = ol.proj.fromLonLat([equipment.lon, equipment.lat]);
|
||||
|
||||
@ -820,6 +823,9 @@
|
||||
data.forEach(worker => {
|
||||
if (VlocationMarkers[worker.id]) {
|
||||
const marker = VlocationMarkers[worker.id]
|
||||
|
||||
updateMarkerProperties(marker, worker)
|
||||
|
||||
const currentCoordinates = marker.getGeometry().getCoordinates();
|
||||
const newCoordinates = ol.proj.fromLonLat([worker.lon, worker.lat]);
|
||||
if (currentCoordinates[0] !== newCoordinates[0] || currentCoordinates[1] !== newCoordinates[1]) {
|
||||
@ -887,6 +893,11 @@
|
||||
await initializeMap();
|
||||
})
|
||||
|
||||
function updateMarkerProperties(marker, properties) {
|
||||
for (let property in properties) {
|
||||
marker.set(property, properties[property])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
}
|
||||
|
||||
// Обработка кликов по маркерам
|
||||
map.on('click', function (evt) {
|
||||
map.on('click', function (evt) {
|
||||
// Получение feature по клику
|
||||
const feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
|
||||
return feature;
|
||||
@ -358,6 +358,9 @@
|
||||
workersTableBody.appendChild(tableRow)
|
||||
if (VlocationMarkers[worker.id]) {
|
||||
const marker = VlocationMarkers[worker.id];
|
||||
|
||||
updateMarkerProperties(marker, worker)
|
||||
|
||||
const currentCoordinates = marker.getGeometry().getCoordinates();
|
||||
const newCoordinates = ol.proj.fromLonLat([worker.lon, worker.lat]);
|
||||
|
||||
@ -375,6 +378,12 @@
|
||||
|
||||
|
||||
window.onload = initializeMap;
|
||||
|
||||
function updateMarkerProperties(marker, properties) {
|
||||
for (let property in properties) {
|
||||
marker.set(property, properties[property])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user