Atlaslog
Atlaslog / OpenLayers / API reference / Select
OpenLayers · API reference

Select

Quick answer

Select is ol.interaction.Select, a handler that picks features by click or box and stores them in a Collection with a separate highlight style. Options include layers, filter, condition, addCondition, removeCondition, toggleCondition, style, hitTolerance and multi. Listen to the select event to read evt.selected and evt.deselected arrays.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
new ol.interaction.Select( options )
Key points
Example
var select = new ol.interaction.Select({
  layers: [vectorLayer],
  hitTolerance: 6,
  multi: false,
  style: new ol.style.Style({
    stroke: new ol.style.Stroke({ color: '#e8a33d', width: 4 }),
    fill: new ol.style.Fill({ color: 'rgba(232, 163, 61, 0.25)' })
  })
});
map.addInteraction(select);

select.on('select', function (evt) {
  var picked = evt.selected[0];
  if (picked) {
    console.log(picked.get('name'));
  } else {
    console.log('取消选中');
  }
});
select.getFeatures().clear();
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Select. https://www.jingweizhi.com/en/openlayers/api/select.html (accessed 2026-11-03).