zcreativelabs / react-simple-maps

Beautiful React SVG maps with d3-geo and topojson using a declarative api.
https://www.react-simple-maps.io/
MIT License
3.12k stars 426 forks source link

get coordinates of click #146

Open mojotti opened 5 years ago

mojotti commented 5 years ago

Hi,

i'm curious is it possible to get coordinates [lng, lat] of click on a map?

I noticed there's onClick method that i can pass to <Geography />, but at least it does not return directly the location of a click.

Can I calculate it from that somehow?

Thanks in advance!

zimrick commented 5 years ago

Hi @mojotti, I think the click coordinates might be a bit trickier. If you are looking to zoom into a country on click you can do this by using the centroid of the country, but the click coordinates themselves would likely require you to do some custom work.

This issue might be relevant: https://github.com/zcreativelabs/react-simple-maps/issues/22