google-map-react/google-map-react

onClick event wrong location when map size change

Open

#914 opened on 2020年8月11日

GitHub で見る
 (18 comments) (2 reactions) (0 assignees)JavaScript (6,224 stars) (888 forks)batch import
help wanted

説明

Describe the bug 🐛

When getting the lat & lng from the onClick event on the map component, lat & lng are incorrect if the bounds of the map changes (for e.g. when switching to full screen using the built-in button).

To Reproduce 🔍

  1. Log the lat & lng that onClick give to the callback onClick={console.log}
  2. Unzoom as far as you can so the issue will be more visible
  3. Take a reference point (nothing special, just find a spot on the map that you will click twice in the next steps). I like to take the south spike of Greenland.
  4. Click on your reference point
  5. Switch the map to fullscreen mode
  6. Click on your reference point again
  7. Check the console and you'll see that both clicks didn't have the same position (Even if you did click twice at the EXACT same location)

And there you go, now you should see the issue.

Expected behavior 💭

The onClick even should give the same location in both cases described above (normal & fullscreen mode).

Additional context

I'm using the version 2.0.8.

コントリビューターガイド