Hide Table of Contents
Application Layouts
Creating custom layer types

The ArcGIS JavaScript API supports tiled and dynamic services from ArcGIS Server 9.3 and later. This support comes from two base classes: TiledMapServiceLayer and DynamicMapServiceLayer. You can extend these base classes to support other layer types such as Open Geospatial Consortium Web Map Services (OGC WMS), and any tiled map service including ArcGIS Server 9.2 cached map services.

Before creating custom layer types, you should have some familiarity with the ArcGIS JavaScript API, especially the DynamicMapServiceLayer and TiledMapServiceLayer classes. It's also helpful to be familiar with creating and extending classes using the dojo.declare methodology. To learn about this see the dojo documentation on working with dojo.declare.

To create a custom layer, you must extend either the DynamicMapServiceLayer or TiledMapServiceLayer class. Extending the GraphicsLayer or creating a custom layer from scratch is not supported. No matter which of the two classes you extend, the workflow is the same:

  1. Use the constructor URL and optional arguments
  2. If required, request data from the server
  3. Process the server response
  4. Initialize the spatial reference
  5. Initialize the initial and full extents
  6. For tiled layers, additionally initialize the tile info
  7. Set the "loaded" property to true
  8. Call onLoad and pass the layer itself as the argument
  9. For dynamic layers, implement getImageUrl. For tiled layers, implement getTileURL

The following samples demonstrate how to create custom layer types using the above pattern: