Openlayers getFeaturesByAttribute不是函数错误
我正在使用openlayers创建地图应用程序,并尝试在按下按钮时更改图层功能图标。 我看过一些例子,他们建议我使用这段代码Openlayers getFeaturesByAttribute不是函数错误,openlayers,angular7,Openlayers,Angular7,我正在使用openlayers创建地图应用程序,并尝试在按下按钮时更改图层功能图标。 我看过一些例子,他们建议我使用这段代码 let feature = this.vectorLayer.getFeaturesByAttribute('id', 1); feature.style = this.iconiSelected; this.vectorLayer.redraw(); 但是我得到的错误是this.vectorLayer.getFeaturesByAttribute不是一个函数 该功能
let feature = this.vectorLayer.getFeaturesByAttribute('id', 1);
feature.style = this.iconiSelected;
this.vectorLayer.redraw();
但是我得到的错误是this.vectorLayer.getFeaturesByAttribute不是一个函数
该功能已经有一个图标,但我想在按下按钮时更改它,这是正确的方法还是有其他方法?请尝试:
let feature = this.vectorLayer.getSource().getFeatureById(1);
feature.setStyle(this.iconiSelected);
请参见此处:该代码适用于OpenLayers 2。您可能正在使用OpenLayers 4或OpenLayers 5。