嘿嘿!
我希望通过悬停/鼠标悬停打开弹出窗口。
我尝试了推荐的但它仍然只能在单击时打开。有人知道缺少什么吗?
任何帮助表示赞赏!
import React from "react";
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
import L from 'leaflet';
const Map = () => {
const renderIcons = () => {
return(
<Marker
position = {[latitude, longitude]}
icon = {getIcon(markerType)}
onMouseOver = {event => event.target.openPopup()}
>
<Popup>
Hello
</Popup>
</Marker>
);
});
return(
<MapContainer ...>
<TileLayer .../>
{renderIcons()}
</MapContainer>
);
}
Run Code Online (Sandbox Code Playgroud)