Module: ol/source/wms

ol/source/wms


Functions

import {createLoader} from 'ol/source/wms';

Creates a loader for WMS images.

Name Type Description
crossOrigin null | string | undefined

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

hidpi boolean (defaults to true)

Use the ol/Map#pixelRatio value when requesting the image from the remote server.

params Object.<string, *> | undefined

WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT and BBOX will be set dynamically. CRS (SRS for WMS version < 1.3.0) will is derived from the proection config.

projection ProjectionLike | undefined

Projection. Default is 'EPSG:3857'.

ratio number (defaults to 1.5)

Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher.

serverType ServerType | undefined

The type of the remote WMS server: mapserver, geoserver, carmentaserver, or qgis. Only needed if hidpi is true.

url string

WMS service URL.

load function | undefined

Function to perform loading of the image. Receives the created HTMLImageElement and the desired src as argument and returns a promise resolving to the loaded or decoded image. Default is decode.

Returns:
Loader.

getFeatureInfoUrl(options, coordinate, resolution){string | undefined}

import {getFeatureInfoUrl} from 'ol/source/wms';

Get the GetFeatureInfo URL for the passed coordinate and resolution. Returns undefined if the GetFeatureInfo URL cannot be constructed.

Name Type Description
options LoaderOptions

Options passed the createWMSLoader() function. In addition to the params required by the loader, INFO_FORMAT should be specified, it defaults to application/json. If QUERY_LAYERS is not provided, then the layers specified in the LAYERS parameter will be used.

coordinate Coordinate

Coordinate.

resolution number

Resolution.

options.crossOrigin null | string | undefined

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

options.hidpi boolean (defaults to true)

Use the ol/Map#pixelRatio value when requesting the image from the remote server.

options.params Object.<string, *> | undefined

WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT and BBOX will be set dynamically. CRS (SRS for WMS version < 1.3.0) will is derived from the proection config.

options.projection ProjectionLike | undefined

Projection. Default is 'EPSG:3857'.

options.ratio number (defaults to 1.5)

Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher.

options.serverType ServerType | undefined

The type of the remote WMS server: mapserver, geoserver, carmentaserver, or qgis. Only needed if hidpi is true.

options.url string

WMS service URL.

options.load function | undefined

Function to perform loading of the image. Receives the created HTMLImageElement and the desired src as argument and returns a promise resolving to the loaded or decoded image. Default is decode.

Returns:
GetFeatureInfo URL.

getLegendUrl(options, resolution){string | undefined}

import {getLegendUrl} from 'ol/source/wms';

Get the GetLegendGraphic URL, optionally optimized for the passed resolution and possibly including any passed specific parameters. Returns undefined if the GetLegendGraphic URL cannot be constructed.

Name Type Description
options LoaderOptions

Options passed the createWMSLoader() function.

resolution number | undefined

Resolution. If not provided, SCALE will not be calculated and included in URL.

options.crossOrigin null | string | undefined

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

options.hidpi boolean (defaults to true)

Use the ol/Map#pixelRatio value when requesting the image from the remote server.

options.params Object.<string, *> | undefined

WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT and BBOX will be set dynamically. CRS (SRS for WMS version < 1.3.0) will is derived from the proection config.

options.projection ProjectionLike | undefined

Projection. Default is 'EPSG:3857'.

options.ratio number (defaults to 1.5)

Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher.

options.serverType ServerType | undefined

The type of the remote WMS server: mapserver, geoserver, carmentaserver, or qgis. Only needed if hidpi is true.

options.url string

WMS service URL.

options.load function | undefined

Function to perform loading of the image. Receives the created HTMLImageElement and the desired src as argument and returns a promise resolving to the loaded or decoded image. Default is decode.

Returns:
GetLegendGraphic URL.

Type Definitions

LoaderOptions{Object}

Properties:
Name Type Description
crossOrigin null | string | undefined

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

hidpi boolean
(defaults to true)

Use the ol/Map#pixelRatio value when requesting the image from the remote server.

params Object.<string, *> | undefined

WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT and BBOX will be set dynamically. CRS (SRS for WMS version < 1.3.0) will is derived from the proection config.

projection ProjectionLike | undefined

Projection. Default is 'EPSG:3857'.

ratio number
(defaults to 1.5)

Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher.

serverType ServerType | undefined

The type of the remote WMS server: mapserver, geoserver, carmentaserver, or qgis. Only needed if hidpi is true.

url string

WMS service URL.

load function | undefined

Function to perform loading of the image. Receives the created HTMLImageElement and the desired src as argument and returns a promise resolving to the loaded or decoded image. Default is decode.

ServerType{'carmentaserver'} {'geoserver'} {'mapserver'} {'qgis'}

Set the server type to use implementation-specific parameters beyond the WMS specification.