Atlaslog
Atlaslog / OpenLayers / API reference / WMSSource
OpenLayers · API reference

WMSSource

Quick answer

WMSSource is ol.source.ImageWMS, an image source that requests one GetMap response per view and drapes it over an image layer. Required url and params carry LAYERS, VERSION and STYLES; ratio, hidpi, serverType, crossOrigin and attributions tune requests. Use updateParams to switch layers and getFeatureInfoUrl to query attributes at a coordinate.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
new ol.source.ImageWMS( options )
Key points
Example
var wms = new ol.source.ImageWMS({
  url: 'https://example.com/geoserver/wms',
  params: {
    LAYERS: 'demo:landuse',
    VERSION: '1.3.0',
    STYLES: '',
    FORMAT: 'image/png',
    TRANSPARENT: true
  },
  serverType: 'geoserver',
  ratio: 1.5,
  crossOrigin: 'anonymous'
});

var layer = new ol.layer.Image({ source: wms, opacity: 0.8 });
wms.updateParams({ LAYERS: 'demo:roads' });
map.on('singleclick', function (evt) {
  var url = wms.getFeatureInfoUrl(
    evt.coordinate,
    map.getView().getResolution(),
    map.getView().getProjection(),
    { INFO_FORMAT: 'application/json' }
  );
  if (url) { fetch(url).then(function (r) { return r.json(); }).then(console.log); }
});
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). WMSSource. https://www.jingweizhi.com/en/openlayers/api/wms-source.html (accessed 2026-11-03).