click point invert zoom react simple map

Solutions on MaxInterview for click point invert zoom react simple map by the best coders in the world

showing results for - "click point invert zoom react simple map"
Clemence
05 Jun 2020
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}
similar questions
queries leading to this page
click point invert zoom react simple map