Atlaslog / Field Notes / OpenLayers layers
Field note · OpenLayers layers
renderer: 'webgl' on ol.layer.Vector blanks the layer
Quick answer
ol.layer.Vector accepts a renderer class or the string 'canvas', not 'webgl', so OpenLayers treats the string as a renderer object and fails when it calls getFeatures. WebGL point rendering lives in a separate layer type.
Symptom
- Uncaught TypeError: renderer.getFeatures is not a function at VectorLayer.renderDeclutter (VectorLayer.js:412).
- map.getLayers().getLength() is correct and the source holds features, yet the canvas stays blank.
- Removing the renderer option makes the same data display normally.
Checklist
- Delete the renderer option and confirm the default canvas path renders.
- Identify the layer class: ol.layer.Vector, ol.layer.WebGLPoints or ol.layer.VectorTile.
- Check the type of the renderer value being passed.
- Read the stack trace for renderDeclutter to confirm an interface mismatch.
Fix
Use new ol.layer.WebGLPoints({ source, style: expressionStyle }) with declarative keys such as 'circle-radius' and 'circle-fill-color', or keep ol.layer.Vector with ol.style.Style for per-feature styling and declutter.
Code
Uncaught TypeError: renderer.getFeatures is not a function
at VectorLayer.renderDeclutter (VectorLayer.js:412)var style = {
'circle-radius': [
'interpolate', ['linear'], ['get', 'value'],
0, 3,
100, 12
],
'circle-fill-color': [
'case',
['>', ['get', 'value'], 80], '#e03131',
'#1c7ed6'
],
'circle-stroke-width': 1,
'circle-stroke-color': '#ffffff'
};
var layer = new ol.layer.WebGLPoints({
source: new ol.source.Vector({ features: features }),
style: style
});
map.addLayer(layer);
Watch out
- Passing an ol.style.Style function to a WebGLPoints layer does nothing because the style must be an expression object.
- Adding renderMode: 'hybrid' to a VectorLayer is ignored; that option belongs to VectorTile.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). renderer: 'webgl' on ol.layer.Vector blanks the layer. https://www.jingweizhi.com/en/cookbook/ol-renderer-wrong.html (accessed 2026-11-03).