Openlayers 3 如何更改geojson文件中已加载点的样式?
我创建了一个脚本,从geojson文件加载功能,如下所示:Openlayers 3 如何更改geojson文件中已加载点的样式?,openlayers-3,Openlayers 3,我创建了一个脚本,从geojson文件加载功能,如下所示: "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [5.53204822887795, 51.609252234043296, 0.0] } }, etc... 然后,我使用样式函数在这些点上创建具有不同颜色和半径
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [5.53204822887795, 51.609252234043296, 0.0]
}
}, etc...
然后,我使用样式函数在这些点上创建具有不同颜色和半径大小的圆:
var styleFunction = function(feature) {
var style = new ol.style.Style({
image: new ol.style.Circle({
radius: calculateRadius(feature),
fill: new ol.style.Fill({
color: 'rgba(255, 0, 0, 0.5)'
}),
stroke: null
})
});
return style;
};
我想更改这些功能的样式,但就我的一生而言,我无法访问样式。我可以访问坐标(我猜是因为它们是点),但获取半径或颜色似乎是不可能的
任何提示?在样式功能中,尝试更改
返回样式代码>到<代码>返回[样式]代码>
看到我的帖子了吗
由于每个功能都要通过style函数完成,因此还可以向geojson添加可以在style函数中读取的属性。如果您想做其他事情,例如根据特征的属性制作正方形或放大地图特征,这是非常棒的