google-map-react: onClick returns wrong lat and lng
Hi, I’ve been using this library and I’ve ran into some weird issues which I can’t seem to find a solution on and even though the library works good it is lacking a bit in documentation and I can’t seem to find any information about this particular problem.
First my code.
addPoint = ({ x, y, lat, lng, event }) => { console.log(x, y, lat, lng, event); this.map.panTo({ lat: lat, lng: lng }); let mark = new this.maps.Marker({ map: this.map, position: { lat: lat, lng: lng } }); }
<GoogleMapReact ... onClick={this.addPoint} ... >
And this is what happens:
So basically, the lat lng gets calculated from the corner on “onClick”. So when I press the upper left corner, it puts the marker in the center. If I press the center, it puts the marker in the lower right corner.
Is it some sort of setting that has to be activated or what is the reason for this? It seems like a bug. Obviously I want the panTo function to center on where it’s clicked and of course I want the marker to be where I actually press, not a quarter of the map wrong.
Other than this, I’ve had a great time working with the library. Thanks for taking the time.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (5 by maintainers)
All versions from 0.34 to 1.0.4 are OK. This issue only applies to version 1.0.5.