function drawGraticulesOld(
svgNode,
{
fontSize = 10,
fontFamily = defaultFontFamily,
tickFill = "black",
stroke = "#ccc",
strokeWidth = 0.5,
outlineStroke = "black",
outlineStrokeWidth = 0.75,
step = [1, 1]
} = {}
) {
const {
projection,
width,
height,
marginLeft,
marginRight,
marginTop,
marginBottom
} = svgNode.props;
const extent = {
topLeft: projection.invert([marginLeft, marginTop]),
topRight: projection.invert([width - marginRight, marginTop]),
bottomRight: projection.invert([
width - marginRight,
height - marginBottom
]),
bottomLeft: projection.invert([marginLeft, height - marginRight])
};
const graticuleGenerator = d3.geoGraticule().step(step);
graticuleGenerator.extent([
[extent.topLeft[0], extent.topLeft[1]],
[extent.bottomRight[0], extent.bottomRight[1]]
]);
const graticules = graticuleGenerator();
const path = d3.geoPath(projection);
const g = d3
.select(svgNode)
.append("g")
.attr("class", "key-graticules")
.attr("font-family", fontFamily)
.attr("font-size", fontSize);
g.append("path")
.attr("class", "graticules")
.attr("fill", "none")
.attr("stroke", stroke)
.attr("stroke-width", strokeWidth)
.attr("d", path(graticules));
g.append("path")
.attr("class", "graticule-outline")
.attr("stroke", outlineStroke)
.attr("storke-width", outlineStrokeWidth)
.attr("fill", "none")
.attr("d", path(graticuleGenerator.outline()));
const graticuleLines = graticuleGenerator.lines();
const longitudes = graticuleLines.filter(
(l) => l.coordinates[0][0] === l.coordinates[1][0]
);
const latitudes = graticuleLines.filter(
(l) => l.coordinates[0][1] === l.coordinates[1][1]
);
const ticks = g.append("g").attr("fill", tickFill);
ticks
.append("g")
.selectAll("text.lat-tick")
.data(latitudes.map((f) => f.coordinates[0]))
.join("text")
.attr("class", "lat-tick")
.attr("x", (d) => projection(d)[0])
.attr("y", (d) => projection(d)[1])
.attr("dx", -3)
.attr("text-anchor", "end")
.attr("dominant-baseline", "middle")
.text((d) => formatLatitude(d[1]));
ticks
.append("g")
.selectAll("text.lon-tick")
.data(longitudes.map((f) => f.coordinates[0]))
.join("text")
.attr("class", "lat-tick")
.attr("x", (d) => projection(d)[0])
.attr("y", (d) => projection(d)[1])
.attr("dy", fontSize + 3)
.attr("text-anchor", "middle")
.text((d) => formatLongitude(d[0]));
return svgNode;
}