Document Maps JavaScript API Reference Manual Industry Standard Layer WMS

WMS

AMap.TileLayer.WMS

A layer class for loading WMS map services that conform to OGC standards, only supports WMS layers with the EPSG3857 coordinate system

Construct a WMS layer object, set the layer properties through WMSLayerOptions

new AMap.TileLayer.WMS(opts: WMSLayerOptions)

Parameter

opts(WMSLayerOptions): WMS Layer Parameters

Attribute

Type

Description

url

String

The URL address of the WMS service, such as' https://ahocevar.com/geoserver/wms '

blend

Boolean

When switching map levels, whether to blend images of different levels, set to false if the image content of the layer is partially transparent

params

Object

Parameters for the GetMap interface of WMS map services compliant with OGC standards, including VERSION, LAYERS, STYLES, FORMAT, TRANSPARENT, etc. Do not add parameters such as CRS, BBOX, REQUEST, WIDTH, HEIGHT, for example:

{

LAYERS: 'topp:states',

VERSION:'1.3.0',

FORMAT:'image/png'

}

zooms

[Number, Number]

Supported zoom level range, default range: [2-30]

opacity

Number

Layer opacity, value range [0 ~ 1], 1 means completely opaque, 0 means completely transparent, default: 1

visible

Boolean

Whether to display, default: true

zIndex

Number

The order value of layer overlay, the larger the number, the higher the layer level, with 1 being the bottom layer. Default: 4

Demo

//Creating a standard WMS layer
var wms = new AMap.TileLayer.WMS({
  url: "https://ahocevar.com/geoserver/wms", //URL address of the WMS service
  blend: false, //Whether images of different levels are blended when switching map levels
  tileSize: 512, //Tile size of the images when loading WMS layer services
  params: {
    LAYERS: "topp:states",
    VERSION: "1.3.0",
  }, //Parameters of the GetMap interface for OGC standard WMS map services
});

map.add(wms); //Add layers to the map

Method

setParams(params)

Set parameters of the OGC standard WMS getMap interface, including VERSION, LAYERS, STYLES, FORMAT, TRANSPARENT, etc.

Parameterparams(Object) Parameter collection,{VERSION: '1.0', ...}

Demo:

wms.setParams({
  LAYERS: "topp:states",
  VERSION: "1.3.0",
});

getParams()

Obtain parameters of the OGC standard WMS getMap interface

return value: (object) Interface Parameters

Demo:

wms.getParams();

setUrl(url)

Set WMS Service Address

Parameterurl (String) Service Address

Demo:

wms.setUrl("https://ahocevar.com/geoserver/wms");

getUrl(url)

Get WMS Service Address

return value: (String) Service Address

Demo:

wms.getUrl();

getOptions()

Get Layer Parameter Information

return value: (Object) Layer Parameter Information

Demo:

wms.getOptions();

getzIndex()

Get layer hierarchy

return value: (Number) zIndex layer hierarchy

Demo:

wms.getzIndex();

setzIndex(zIndex)

Set the layer hierarchy, the larger the number, the higher the layer hierarchy

ParameterzIndex (Number) Layer hierarchy value

Demo:

wms.setzIndex(10);

getOpacity()

Get layer transparency

return value: (Number) Opacity layer opacity

Demo:

wms.getOpacity();

setOpacity(opacity)

Set the layer opacity, range [0 ~ 1], 1 means completely opaque, 0 means completely transparent

Parameteropacity (NumberLayer opacity

Demo:

wms.setOpacity(0.5);

getZooms()

Get the level range that this layer can display, default range: [2-30]

return value: ([Number, Number]The level range that this layer can display

Demo:

wms.getZooms();

setZooms(zooms)

Set the Level Range of the Layer

Parameterzooms([Number, Number]The Zoom Range of the Layer

Demo:

wms.setZooms([8,12]);

show()

Set Layer Visible

Demo:

wms.show();

hide()

Set Layer Hidden

Demo:

wms.hide();

Event

Event Name

Description

complete

Tile Load Finished Event

For event object property descriptions, go to:MapsEvent