Custom DynamicLayer

This sample demonstrates how to create a custom dynamic layer with a WMS service. The Cadastre en Bretagne - Parcelles data can be located the through the République Française and is accessible as a WMS service (https://cms.geobretagne.fr/).

This sample uses a WMS service for demonstration purposes only. The has a WMSLayer type that should be used for working with data in WMS. See the WMSLayer sample for more details.

To create a custom dynamic layer, you must call createSubclass() on BaseDynamicLayer. We'll call the custom dynamic layer CustomWMSLayer and give it two public properties that can be watched for changes. They are be used to generate a URL to request an image from a WMS server. The properties are:

  • mapUrl - specifies the URL to a WMS service
  • mapParameters - specifies query parameters that will be used when fetching image from the server
1
2
3
4
5
6
7
const CustomWMSLayer = BaseDynamicLayer.createSubclass({
  properties: {
    mapUrl: null,
    mapParameters: null
  }
  // ...
});

The CustomWMSLayer implements the getImageUrl() method to generate the URL to an image for a given extent, width, and height. This method manipulates values of the mapUrl and mapParameters properties to generate the URL to an image which will be displayed in the view.

1
2
3
4
5
6
7
// Override getImageUrl() method to generate URL
// to an image for a given extent, width and height.
getImageUrl: function (extent, width, height) {
  const urlVariables = this._prepareQuery(this.mapParameters, extent, width, height);
  const queryString = this._joinUrlVariables(urlVariables);
  return this.mapUrl + "?" + queryString;
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close