以编程方式创建填充组件的弹出窗口



由于项目要求,我不能在渲染上使用Map组件,而是使用可以用地图实例化的<div id="map"/>

我不知道如何使用自定义组件以编程方式向其添加Popup

我知道我可以去:

this.popup.setLatLng(latLng);
this.popup.setContent("<div>Simple content</div>");
this.popup.openOn(map);

但这不允许我使用 React 生命周期设置自定义组件。

使用时,我能够看到弹出窗口:

<Popup position={this.state.position} key={this.state.key}>
<MyChartComponent/>
</Popup>

有没有办法以编程方式进行存档?

我通过使用react-dom中的render实现了我想要的,如下所示:

this.popup.setContent('');
this.popup.setLatLng(latlng);
if (!this.popup.isOpen()) {
this.popup.openOn(map);
render(<MyChartComponent />, this.popup._contentNode);
}

最新更新