mapaCompleto = {
const width = 300;
const height = 300;
const zoom = 14;
const lon = -58.5638;
const lat = -34.6037;
function lonLatToTile(lon, lat, zoom) {
const x = Math.floor((lon + 180) / 360 * Math.pow(2, zoom));
const y = Math.floor((1 - Math.log(Math.tan(lat * Math.PI/180) + 1 / Math.cos(lat * Math.PI/180)) / Math.PI) / 2 * Math.pow(2, zoom));
return [x, y];
}
const [tileX, tileY] = lonLatToTile(lon, lat, zoom);
const container = d3.create("div")
.style("position", "relative")
.style("width", `${width}px`)
.style("height", `${height}px`)
.style("border", "1px solid #ccc");
container.append("img")
.attr("src", `https://tile.openstreetmap.org/${zoom}/${tileX}/${tileY}.png`)
.style("position", "absolute")
.style("width", "100%")
.style("height", "100%")
.style("object-fit", "cover");
const svg = container.append("svg")
.attr("width", width)
.attr("height", height)
.style("position", "absolute")
.style("top", 0)
.style("left", 0);
const projection = d3.geoMercator()
.fitExtent([[0, 0], [width, height]], tresDeFebrero);
const pathGenerator = d3.geoPath()
.projection(projection);
svg.append("path")
.datum(tresDeFebrero.features[0])
.attr("d", pathGenerator)
.attr("fill", "rgba(173, 216, 230, 0.3)")
.attr("stroke", "black")
.attr("stroke-width", 1);
return container.node();
}