如何禁用MapBox中的“关闭所有弹出窗口”?

问题描述 投票:0回答:2

不久前,人们很难在 Mapbox 中点击地图时关闭所有弹出窗口(如何在 Mapbox gl 中以编程方式关闭所有弹出窗口?)。

他们已将其更改为默认行为,这很好,但不适合我当前的项目。

如何在点击时不关闭所有弹出窗口?

一旦禁用:

如何以编程方式在单击时关闭选定的弹出窗口?

mapbox mapbox-gl-js
2个回答
1
投票

像这样:

const popup = new mapboxgl.Popup({ closeOnClick: false });

map.on('click', () => popup.remove());

0
投票

我正在研究reactJS,只需在下面的 Popup 组件示例中将 closeOnClick 属性添加为 false

<Popup
        longitude={Number(longitude)}
        latitude={Number(latitude)}
        closeOnClick={false}
      >
<!--modal content-->
</Popup>
© www.soinside.com 2019 - 2024. All rights reserved.