FRAMES | NO FRAMES Description | Parameters | Examples | Response
Generate KML (Operation)
URL http://<mapservice-url>/generateKml
Parent Resource Map Service
Required Capability Map

Description

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.

Note that 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.

Parameters

Parameter Details
docName 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
layers 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
layerOptions 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.

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/generatekml?docName=Test+Name&layers=1,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="http://earth.google.com/kml/2.1">  
<NetworkLink>
  <open>1</open>
  <name>Test Name</name>
  <Snippet>Test Map Service Description</Snippet>  
  <Url>
    <viewRefreshMode>onStop</viewRefreshMode>
    <viewRefreshTime>2</viewRefreshTime>
    <href>http://myhost:8399/arcgis/services/Maps/USGeo/MapServer/KmlServer</href>
    <viewFormat>
    <![CDATA[
    Composite=true&LayerIDs=0,1&BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]&ImageSize=[horizPixels],[vertPixels]
    ]]>
    </viewFormat>
  </Url>
</NetworkLink>
</kml>