Atlaslog
Atlaslog / OpenLayers / Tutorial / Vector layers and styling
OpenLayers · Tutorial

Vector layers and styling

Quick answer

This tutorial walks through the four-level OpenLayers vector structure: ol.layer.Vector, ol.source.Vector, ol.Feature and geometry classes. It shows feature get and set properties, three ways to assign styles with ol.style.Style, Fill, Stroke, Circle and Text, style functions that return arrays, and resolution-based label switching. It also explains why layer.changed is needed after mutating attributes. Readers can build attribute-driven symbology and debug styles that never refresh.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
Key points
Example
var feature = new ol.Feature({
  geometry: new ol.geom.Point(ol.proj.fromLonLat([116.404, 39.915])),
  name: '王府井',
  level: 'high'
});

feature.get('name');        // '王府井'
feature.set('level', 'low');
feature.setStyle(new ol.style.Style({
  image: new ol.style.Circle({
    radius: 6,
    fill: new ol.style.Fill({ color: '#1f5fd0' }),
    stroke: new ol.style.Stroke({ color: '#fff', width: 2 })
  })
}));
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Vector layers and styling. https://www.jingweizhi.com/en/openlayers/tutorials/vector-style.html (accessed 2026-11-03).