我正在使用傳單集群庫(v1.1.8)并且我正在嘗試傳遞選項。
我希望應用程式在懸停時停止顯示覆寫范圍(見下圖)。

但是每當我添加選項時showCoverageOnHover={false}它都不起作用。
<MarkerClusterGroup showCoverageOnHover={false}>
<MarkersLayer
stationsToDisplay={stationsToDisplay}
stationsList={stationsList}
refreshStationsList={this.refreshStationsList}
StandsToDisplay={StandsToDisplay}
CARToDisplay={CARToDisplay}
selectedOption={selectedOption}
/>
</MarkerClusterGroup >
該檔案表明,正確的代碼的傳球選擇將是:
<MarkerClusterGroup showCoverageOnHover={false} />
但是,我已經作為道具傳遞了:
<MarkerClusterGroup >
<MarkersLayer
stationsToDisplay={stationsToDisplay}
stationsList={stationsList}
refreshStationsList={this.refreshStationsList}
StandsToDisplay={StandsToDisplay}
CARToDisplay={CARToDisplay}
selectedOption={selectedOption}
/>
</MarkerClusterGroup >
那么我如何通過選項?我已經嘗試過,如下所示,但這不起作用
<MarkersLayer
stationsToDisplay={stationsToDisplay}
stationsList={stationsList}
refreshStationsList={this.refreshStationsList}
StandsToDisplay={StandsToDisplay}
CARToDisplay={CARToDisplay}
selectedOption={selectedOption}
showCoverageOnHover={false}
/>
我在反應方面是個菜鳥,所以任何觀察和建議都將不勝感激!多謝
uj5u.com熱心網友回復:
根據 1.1.8 上的新 API 版本,這樣的事情會起作用:
<MarkerClusterGroup showCoverageOnHover={false} >
<MarkersLayer
stationsToDisplay={stationsToDisplay}
stationsList={stationsList}
refreshStationsList={this.refreshStationsList}
StandsToDisplay={StandsToDisplay}
CARToDisplay={CARToDisplay}
selectedOption={selectedOption}
/>
</MarkerClusterGroup >
另一個使用示例markerClusterGroup可能很有用:
import MarkerClusterGroup from 'react-leaflet-markercluster';
<MarkerClusterGroup>
<Marker position={[49.8397, 24.0297]} />
<Marker position={[52.2297, 21.0122]} />
<Marker position={[51.5074, -0.0901]} />
</MarkerClusterGroup>;
uj5u.com熱心網友回復:
通過在類本身中添加引數,解決了這個問題:
class MarkerClusterGroup extends MapLayer {
createLeafletElement(props) {
const el = new L.markerClusterGroup(
{
props,
showCoverageOnHover:false,
disableClusteringAtZoom: 13,
}
);
this.contextValue = {
...props.leaflet,
layerContainer: el
};
return el;
}
}
export default withLeaflet(MarkerClusterGroup);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/334951.html
標籤:javascript 反应 反应原生 反应传单 传单.markercluster
上一篇:ReactNative,reactnavigation,如何使用Drawer回傳()到上一個螢屏,而不是第一個螢屏?
