I have a usa map and behind i have a voronoi map to divide the usa in areas. But i don't want the voronoi to get out of the limits of the map.
this is the code that i currently have. Ty for the help
var projectedPoints = [];
for (var i = 0; i < data.length; i++) {
projectedPoints.push(projection(data[i].location));
}
svg.selectAll("path")
.data(voronoi.polygons(projectedPoints))
.enter()
.append("path")
.attr("class", "teams-cells")
.attr("id", function (d, i) { return data[i].abbreviation; })
.attr("d", function (d) { return "M" + d.join("L") + "Z"; })
.attr("fill", function (d, i) { return data[i].color; })
.on('mouseover', function (d, i) {
tooltip.transition()
.duration(200)
.style("opacity", .9);
tooltip.html(data[i].team + "<br/>")
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on('mouseout', function () {
tooltip.transition()
.duration(500)
.style("opacity", 0);
})
.on("click",function (d,i) {
verify(data[i]);
});
svg.append("path")
.datum(topojson.feature(topology, topology.objects.land))
.attr("d", path);