Generate KML


The generateKml operation is performed on a map service resource. The result of this operation is a KML document wrapped in a KMZ file. The document contains a network link to the KML Service endpoint with properties and parameters you specify.


The viewRefreshMode tag of the resulting network link will be set to onStop for raster data and to onRequest if it contains vector data. You can provide arguments to the generateKML operation as query parameters defined in the parameters table below.

Request Parameters




Description: The name of the resulting KML document. This is the name that appears in the Places panel of Google Earth.

Example: docName=Test+Name


Description: The layers to perform the generateKML operation on. The layers are specified as a comma-separated list of layer ids.

Syntax: layers=<layerId1>,<layerId2>

Where layerId1 ,layerId2 are the layer ids returned by the map service resource.

Example: layers=2,4,7


Description: The layer drawing options. Based on the option chosen, the layers are drawn as one composite image, as separate images, or as vectors. When the KML capability is enabled, the ArcGIS Server administrator has the option of setting the layer operations allowed. If vectors are not allowed, then the caller will not be able to get vectors. Instead, the caller receives a single composite image.

Values: composite | separateImage | nonComposite

  • composite: (Default) All layers as a single composite image. Layers cannot be turned on and off in the client.
  • separateImage: Each layer as a separate image.
  • nonComposite: Vector layers as vectors and raster layers as images.

Example Usage

Example 1: Generate KML operation.,2&layerOptions=separateImage

KML Response Example

Below is a typical KML document wrapped in an example KMZ response:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">  
  <name>Test Name</name>
  <Snippet>Test Map Service Description</Snippet>