KML is supported as an output format when using the REST API in the following ways:
- Map and image service footprints
- Fused raster representation for map and image services
- KML Regions and Dynamic Ground Overlays
- Query Results
- Geocode Results
- Geoprocessing task results
- Custom raster or vector compositions corresponding to selected layers from a map service
KML options are not available when services are secured using token based authentication.
The following options are available for requesting data in KML format:
- f=kmz: Used for requesting kml as an output format using the f parameter in the URL. The response is a KML document wrapped in a KMZ file. It may be a footprint or the result of an operation.
In the following example, a request is made for a KML footprint of a map service of Naperville shelters:
For more information about format output options, see Output formats.
- KML Region or ground overlay documents: Used for requesting a KML Region or ground overlay document wrapped in a KMZ file. In comparison to "f=kmz", this option is used when you click the "View In: ArcGIS Earth" link when in Services Directory.
The following is a URL request for a map service returned as a KML Region:
The next example shows a URL to an image service. Image services are always returned as ground overlay KML:
- Generate KML operation: You can use the Generate KML operation if you want to generate a KMZ document that contains a network link to the KML Service endpoint with properties and parameters you specify. When using Services Directory, you navigate to the page of the map service you want to view. From the Map Operations list, click the Generate KML link.
A server administrator can limit or disable some options. For example, the administrator may have disabled the ability for the server to return vector features, or the administrator may have set a limit on how many KML features the server can return.
For more information, see Generate KML (Operation).