反应openlayers渲染层复选框生命周期

问题描述

我有问题,如何渲染层,当我检查复选框与混凝土层。

class Map extends React.Component{
constructor(props){
super(props);
}

componentDidMount(){

//init
const map = new Map({
target:'map'
layers:[
new TileLayer({
source: new OSM()
}),vectorLayerShops,vectorLayerInstitutions,vectorLayerStadiums
],view: new View({
center: fromLonLat([0,0]),zoom: 5
})
});

map.on('singleclick',function(event){
if(map.hasFeatureAtPixel(event.pixel) === true) {
var coordinate = event.coordinate;
var feature = map.forEachFeatureAtPixel(event.pixel,function(feature,layer){
return feature;
})
if(feature){
 content.innerHTML = getMarkerInfoContent(feature);
overlay.setPosition(coordinate);
   }
  }
 }
}

vectorLayers在我不使用react(pure JS)时可以正常工作, 但现在图层没有显示出来。如何使用叠加层中的内容到达地图中的图层。

请帮助我如何做(开放层)反应

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...