react simple map listen to mouse click code example
Example: click point invert zoom react simple map
//And, the onClick factory for Geography-ies, that will take Map's this.getScale as scale argument:
function onGeographyClick (scale, projection, onCoordinatesClick) {
const gp = geoPath().projection(projection)
return function (geo, evt) {
const dim = evt.target.getBoundingClientRect()
const cx = evt.clientX - dim.left
const cy = evt.clientY - dim.top
const [orgX, orgY] = gp.bounds(geo)[0]
onCoordinatesClick(projection.invert([orgX + cx / scale(), orgY + cy / scale()]))
}
}