【发布时间】:2018-01-07 02:02:32
【问题描述】:
我需要使页面加载后生成的一些 react-leaflet 映射无效:
maps = [];
mapData = mapData.map(function(assetf,index){
return(
assetf.map(function(asset, index){
var ind = index;
var indHash = "#" + ind;
var indExtra = ind + "ex";
maps.push(indExtra);
return(
<li key={ind}>
<div>{asset.description}</div>
<Map id={indExtra} style={mapStyles} center={asset.point.coordinates} zoom={7}>
<TileLayer
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
</Map>
</li>
)
})
)
});
我尝试使用此代码:
var i;
for(i=0; i < maps.length; i++){
maps[i].invalidateSize(true);
}
但是抛出了这个错误:
Uncaught (in promise) TypeError: maps[i].invalidateSize is not a function
谢谢,埃德。
【问题讨论】:
标签: jquery node.js reactjs leaflet react-leaflet