Skip To Content

Viewing services as KML

By default, map services and image services are also available as a Keyhole Markup Language (KML) network links. This means that any application capable of viewing KML, such as Explorer for ArcGIS, ArcGlobe, and Google Earth, can consume these services.

ArcGIS for Server uses Representational State Transfer (REST) to expose information about your services through a series of endpoints, or URLs. Users only need to reference the appropriate REST URLs that return KML to consume the service as KML. Additionally, ArcGIS Server Manager allows users to create highly customized KML content as a separate set of non-REST URLs in the form of prepackaged KML network link documents.

How KML network links work with map, geocode, geoprocessing, and image services

KML network links are a way of viewing dynamic KML content over the web. They can include details on refresh intervals and other behavioral properties and can be embedded within zipped KML (KMZ) files. For simplicity, KML/KMZ files that contain network link information will be referred to as network link documents for the remainder of this topic.

The default KML network link provided through the map service and image service REST endpoints displays the service as a ground overlay, that is, as an image draped on the surface of the globe. If the service is a cached map service in a supported coordinate system (WGS 1984 Web Mercator, WGS 1984 Web Mercator [Auxiliary Sphere], or any other cylindrical projection), the ground overlay is also returned using Regions. Regions expose a hierarchical collection of images and are recommended for optimum performance.

Additional REST KML network links that can be accessed include map service layer query operations, geocode address and reverse geocode operations, and results of submitted geoprocessing jobs. These returned vectors are symbolized as in the original service source documents and raster ground overlays (geoprocessing service only).

Another option available to map services is to generate a custom KML network link. Creating a custom KML network link can be done through ArcGIS Server Manager, the Services Directory, or by hand in a KML client. This technique allows the served KML to include combinations of raster and vector elements rather than just the single ground overlay image provided through the default REST endpoint. For example, if you wanted extruded building footprints in the map service, you would need to generate a custom KML network link. See Authoring maps for publishing as KML and Managing KML network links for more details on this authoring process.

Finding the URL for a particular KML service

The Services Directory is an application included with ArcGIS for Server that helps you navigate REST-related information about your services, including URLs. To open the Services Directory, use the installed shortcut or open a browser and navigate to http://gisserver.domain.com:6080/arcgis/rest/services. Once you locate your KML service in the directory, right-click View In: Google Earth and copy the shortcut to get the link.

The default REST URLs for map and image services are built directly from the pieces:

http://gisserver.domain.com:6080/arcgis/rest/services/folder/service/service type/kml/service.kmz

The various names are defined by the publisher when the service is created, and the service type is either MapServer or ImageServer.

The following is an example of a REST URL that connects to a map service as a KML network link:

http://gisserver.domain.com:6080/arcgis/rest/services/MyKMLService/MapServer/kml/mapImage.kmz

The MapServer REST URL for generating a custom KML network link document is located on the same Services Directory page as the MapServer REST endpoint. Its URL follows the same pattern as before but ends in generateKML.kmz. Opening this link presents a page that allows definition of specific network link properties. Clicking Generate KML creates a custom network link document that can then be copied to any virtual directory to publish.

Additionally, selecting a map service layer link, then choosing Query Layer as the operation, opens the query layer page.

Choosing KMZ as the format creates a network link URL that you can paste in a network link document:

http://gisserver.domain.com:6080/arcgis/rest/services/M_Portland_FGDB/MapServer/7/query?text=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&where=&returnGeometry=true&outSR=&outFields=&f=kmz

With administrator privileges, you can access your map or image service in ArcCatalog or the Catalog window in ArcGIS for Desktop and look up the URL to the non-REST KML service. This URL can be used for building custom KML network links by hand in a KML client. To find the URL, right-click the service name and choose Service Properties. On the Service Editor, click Capabilities > KML.