react-simple-maps icon indicating copy to clipboard operation
react-simple-maps copied to clipboard

get coordinates of click

Open mojotti opened this issue 6 years ago • 1 comments

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!

mojotti avatar Aug 07 '19 13:08 mojotti

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

zimrick avatar Aug 08 '19 10:08 zimrick