mapaViaje = {
const container = yield htl.html`<div style="height: 1000px;">`;
const map = L.map(container);
var autoPanPadding = L.point(5, 5);
const layerEcuador = L.geoJSON(geoEcuador, {
style: {
color: 'blue',
weight: 0.5
}
}).addTo(map);
map.fitBounds(layerEcuador.getBounds(), { maxZoom: 9 });
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);
const layerColombia = L.geoJSON(geoColombia, {
style: {
color: 'blue',
weight: 0.5
}
}).addTo(map);
map.fitBounds(layerColombia.getBounds(), { maxZoom: 9 });
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);
map.setView([4, -74.8], 6);
const nombreCaminoMap = {
"Ibagué - Cartago": "Quindío",
"Cartago - Novita": "Chocó",
"Nare - Medellín": "Antioquia",
"Pasto - Mocoa": "Putumayo",
"Quito - Napo": "Napo",
"Huila - Caquetá": "Caquetá"
};
function caminoSeleccionado(camino) {
const nombreRealDelCamino = nombreCaminoMap[camino];
const filtradas = data
.filter(d => d.camino === nombreRealDelCamino && d.otros === false)
.map(d => ({
url: d.url,
autor: d.autor,
nombre: d.obras,
fecha: d.fecha,
repositorio: d.repositorio
}));
return filtradas;
}
// Iterar sobre cada feature en el GeoJSON para las líneas
caminosCargueros.features.forEach(feature => {
const lineName = feature.properties.name;
const urlsFiltradas = caminoSeleccionado(lineName);
feature.properties.images = urlsFiltradas;
});
// Filtrar los puntos de caminosCargueros
const puntosCargueros = caminosCargueros.features.filter(feature => feature.geometry.type === 'Point');
// Asociar nombres de línea con colores usando d3.schemeCategory10
const colorScale = d3.scaleOrdinal(d3.schemeCategory10);
const lineColors = {
"Ibagué - Cartago": colorScale(0),
"Cartago - Novita": colorScale(1),
"Nare - Medellín": colorScale(2),
"Pasto - Mocoa": colorScale(3),
"Quito - Napo": colorScale(4),
"Huila - Caquetá": colorScale(5),
};
// Configuración para las líneas
const markersLines = L.markerClusterGroup();
const markerLinesLayer = L.geoJSON(caminosCargueros, {
style: function (feature) {
const lineName = feature.properties.name;
return {
weight: 8,
opacity: 0.8,
color: lineColors[lineName]
};
},
onEachFeature: function (feature, layer) {
if (feature.properties && feature.properties.name) {
layer.on('click', function () {
layer.openPopup();
});
layer.bindPopup(function () {
var popupContent = `<h1>${feature.properties.name}</h1><div id="image-carousel">`;
feature.properties.images.forEach(function (imageInfo) {
popupContent += `
<div class="image-container">
<img src="${imageInfo.url}"/>
<div class="image-info">
<h3>${imageInfo.nombre}</h3>
<p>${imageInfo.autor}</p>
<p>${imageInfo.fecha}</p>
<a href="${imageInfo.repositorio}" target="_blank"><iconify-icon icon="ph:archive-light"></iconify-icon></a>
</div>
</div>`;
});
popupContent += `</div>`;
return popupContent;
}, {
autoPanPadding: autoPanPadding
});
layer.on('mouseover', function () {
layer.setStyle({ weight: 12, opacity: 1 });
});
layer.on('mouseout', function () {
layer.setStyle({ weight: 8, opacity: 0.8 });
});
}
}
});
markersLines.addLayer(markerLinesLayer);
// Configuración para los puntos
const markersPoints = L.markerClusterGroup();
const markerPointsLayer = L.geoJSON(puntosCargueros, {
onEachFeature: function (feature, layer) {
if (feature.properties && feature.properties.name) {
layer.bindPopup(`<h1>${feature.properties.name}</h1> <img src='${feature.properties.image}'/> <p>${feature.properties.description}</p>`, {
autoPanPadding: autoPanPadding
});
layer.on('mouseover', function (e) {
const hoveredMarker = e.target;
hoveredMarker.bindPopup(`<h1>${feature.properties.name}</h1>`);
hoveredMarker.openPopup();
});
layer.on('mouseout', function (e) {
const hoveredMarker = e.target;
hoveredMarker.closePopup();
});
}
}
});
markersPoints.addLayer(markerPointsLayer);
map.addLayer(markersLines);
map.addLayer(markersPoints);
}