Custom DynamicLayer

This device does not support 3D.

View the system requirements for more information.

This sample demonstrates how to create a custom dynamic layer with a WMS service. The WMS service is accessed from geobretagne server.

This sample uses a WMS service for demonstration purposes only. The ArcGIS API for JavaScripts 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. They will 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
var 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.

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

Sample search results

TitleSample

There were no match results from your search criteria.