Hide Table of Contents
View WMS layer sample in sandbox
WMS layer


This sample shows how to work with an OGC Web Map Service (WMS). When WMSLayers are added to the map only the specified layers are displayed.


<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Map with WMS</title> 

    <link rel="stylesheet" href="https://js.arcgis.com/3.33/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" href="https://js.arcgis.com/3.33/esri/css/esri.css">
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      body {
        background-color: #FFF;
        overflow: hidden;
        font-family: "Trebuchet MS";
    <script src="https://js.arcgis.com/3.33/"></script> 
      var map;

      require(["esri/map", "esri/layers/WMSLayer", "esri/config", "dojo/domReady!"],
        function(Map, WMSLayer, esriConfig) {

          esriConfig.defaults.io.proxyUrl = "/proxy/";
          map = new Map("map", {
            basemap: "streets",
            center: [-98, 37],
            zoom: 5

          var wmsLayer = new WMSLayer("https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer", {
            format: "png",
            visibleLayers: [2]
      <div id="map">
Show Modal