Class: WMS

cercaliagl.layer/WMS


Layer for tile data from WMS servers.

Example usage:

const map = new cercaliagl.Map({
  target: 'map',
  center: new cercaliagl.LonLat(-3.6918373493421393, 40.41706664527052),
  zoom: 13,
});

map.whenReady(() => {
  const servers = [
    'http://c1.cercalia.com/cgi-bin/mapserv?map=/usr/nexus/cercalia2/a9/barris_pg.map',
    'http://c2.cercalia.com/cgi-bin/mapserv?map=/usr/nexus/cercalia2/a9/barris_pg.map',
    'http://c4.cercalia.com/cgi-bin/mapserv?map=/usr/nexus/cercalia2/a9/barris_pg.map',
    'http://c6.cercalia.com/cgi-bin/mapserv?map=/usr/nexus/cercalia2/a9/barris_pg.map'
  ];

  const wmsParams = {
    service: 'WMS',
    version: '1.1.1',
    request: 'GetMap',
    format: 'image/png',
    layers: 'default',
    srs: 'EPSG:3857',
    width: '1024',
    height: '1024',
    exceptions: 'application/vnd.ogc.se_inimage'
  };
  const wmsLayer = new cercaliagl.layer.WMS({
    url: servers,
    controls: [],
    params: wmsParams,
    tileSize: 1024
  });
  map.addLayer(wmsLayer);
});

new WMS(options)

Name Type Description
options

Options

Name Type Description
layerId string

Layer id

attribution string

Attribution HTML for this layer. This value is visible in module:cercaliagl/control/Logo~Logo.

url string | Array.<string>

URL or arary of URLS of WMS Service.

tileSize number

Tile size in pixels

params module:cercaliagl/layer/WMS~WMSParameters
label string
startParamsCharacter string

Methods

getAttribution(){string}

Get attribution string HTML

getLabel(){string}

Map label used in layer switcher.

Returns:
Name

getLayerId(){string}

Get Layer id.

getParams(){Object.<string, (string|boolean|number)>}

Get layer params

refresh()

Refresh WMS

updateParams(params)

Update WMS parameters and refresh WMS images loaded.

Name Type Description
params

Params

Name Type Description
service string

Service. Default WMS.

version string

WMS Version. Default 1.1.1.

request string

Request. Default GetMap

format string

Format. Default image/png.

projection string

Projection. Default EPSG:3857.

srs string

SRS. Default: EPSG:3857.

transparent boolean

Transparent. Default true.

layers string

Layers. Default default.

width number

Width in pixels. Default: 1024.

height number

Height in pixels. Default `1024'

startParamsCharacter string

Start params character. Default &.

styles string

styles.