Generate KML

URL:
https://<mapservice-url>/generateKml
Methods:
GET
Required Capability:
Map
Version Introduced:
9.3

Description

The generateKml operation is performed on a map service resource and returns 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.

Request parameters

ParameterDetails

docName

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

Example

1
docName=Test Name

layers

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

Syntax

1
2
//where layerId1 and layerId2 are the layer IDs returned by the map service resource
layers=<layerId1>,<layerId2>

Example

1
layers=2,4,7

layerOptions

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 that are allowed. If vectors are not allowed, the caller will not be able to get vectors. Instead, the caller receives a single composite image. The following options are supported values for the layerOptions parameter:

  • 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.

Values: composite | separateImage | nonComposite

Example usage

The following is a sample request URL used for the generateKml operation:

1
https://machine.domain.com/webadaptor/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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="https://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>https://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>

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

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