Single Image WMS

wms11 image6

Example of a single image WMS layer.

WMS can be used as an Image layer, as shown here, or as a Tile layer, as shown in the Tiled WMS example example. Tiles can be cached, so the browser will not re-fetch data for areas that were viewed already. But there may be problems with repeated labels for WMS servers that are not aware of tiles, in which case single image WMS will produce better cartography.

import 'ol/ol.css';
import ImageWMS from 'ol/source/ImageWMS';
import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import View from 'ol/View';
import {Image as ImageLayer, Tile as TileLayer} from 'ol/layer';

var layers = [
  new TileLayer({
    source: new OSM(),
  new ImageLayer({
    extent: [-13884991, 2870341, -7455066, 6338219],
    source: new ImageWMS({
      url: 'https://ahocevar.com/geoserver/wms',
      params: {'LAYERS': 'topp:states'},
      ratio: 1,
      serverType: 'geoserver',
  }) ];
var map = new Map({
  layers: layers,
  target: 'map',
  view: new View({
    center: [-10997148, 4569099],
    zoom: 4,
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Single Image WMS</title>
    <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
    <script src="https://unpkg.com/elm-pep"></script>
      .map {
        width: 100%;
    <div id="map" class="map"></div>
    <script src="main.js"></script>
  "name": "wms-image",
  "dependencies": {
    "ol": "6.5.0"
  "devDependencies": {
    "parcel": "^2.0.0-beta.1"
  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build --public-url . index.html"