[英]How to stop flickering of Markers on mouseover and onmouseout events in react-google-maps?
I'm using React.js and react-google-maps to implement this. 我正在使用React.js和react-google-maps来实现这一点。 I'm trying to display the InfoWindow on Hovering any Marker and hiding when mouse leaves the Marker. 我试图显示InfoWindow悬停任何标记并在鼠标离开标记时隐藏。 Here's the link for code. 这是代码的链接。 ( https://codesandbox.io/s/loving-microservice-88oop ) ( https://codesandbox.io/s/loving-microservice-88oop )
It's quite simple actually. 实际上这很简单。 Let's go through this together. 让我们一起来看看。
How to prevent this: 如何防止这种情况:
Option 1: Change your hover so that it's also applied to the popup and not just for the marker 选项1:更改悬停,以便它也应用于弹出窗口,而不仅仅是标记
Option 2: Change the markers position. 选项2:更改标记位置。 You can do this by changing this line (line 36 in your example): 您可以通过更改此行(示例中的第36行)来执行此操作:
position={{
lat: selectedPark.geometry.coordinates[1] + 0.0500,
lng: selectedPark.geometry.coordinates[0]
}}
I solved this by using pixelOffset option available as props. 我通过使用pixelOffset选项作为道具来解决这个问题。 In the other answer, It was using lat as offset but when we zoom, it no longer persists in that position. 在另一个答案中,它使用lat作为偏移,但是当我们缩放时,它不再保持在那个位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.