问题描述
我有一个动态生成的图层列表,它是 react-leaflet 库组件,我想在列表顶部创建图层按钮,它将打开/关闭所有其他图层,我想使用 onclick 事件并通过以下方式控制它我自己,但没有这样的事件,所以有什么办法可以做到吗?
export const Points = ({
points,setShowPointModal,setPointId,setIsEditPointMode,setComaprePointId,isPointsNonEditable,uniqueObjectTypes
}) => {
const handleClick = (id) => {
setPointId(id);
setIsEditPointMode(true);
setShowPointModal(true);
};
return (
<>
<LayersControl position="topleft">
{uniqueObjectTypes.map(el=>{
return(<LayersControl.Overlay key={el.Object_Type_Id} checked name={el.Object_Type_Name}>
<LayerGroup>
{points.filter(poi=> poi.Object_Type_Id===el.Object_Type_Id).map(
({
Id: id,coordinates,Name_object,Description: description,Image: image,emissions,owner_type,Environments
}) => (
<>
<Point
id={id}
key={id}
coordinates={coordinates}
Name_object={Name_object}
description={description}
image={image}
emissions={emissions}
owner_type={owner_type}
handleClick={handleClick}
setComaprePointId={setComaprePointId}
isPointsNonEditable={isPointsNonEditable}
EnvironmentAttachment={Environments}
/>
</>
))}
</LayerGroup>
</LayersControl.Overlay>)
})}
</LayersControl>
</>
);
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)