1//And, the onClick factory for Geography-ies, that will take Map's this.getScale as scale argument:
2
3function onGeographyClick (scale, projection, onCoordinatesClick) {
4 const gp = geoPath().projection(projection)
5
6 return function (geo, evt) {
7 const dim = evt.target.getBoundingClientRect()
8 const cx = evt.clientX - dim.left
9 const cy = evt.clientY - dim.top
10 const [orgX, orgY] = gp.bounds(geo)[0]
11
12 onCoordinatesClick(projection.invert([orgX + cx / scale(), orgY + cy / scale()]))
13 }
14}