Viewing services as KML
By default, every published ArcGIS Server map service or image service is also available as a Keyhole Markup Language (KML) network link. This means that any application capable of viewing KML, such as ArcGIS Explorer, ArcGlobe, and Google Earth, can consume your ArcGIS Server services.
ArcGIS 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 exposes a separate set of non-REST URLs designed to work with Manager users creating highly customized KML content for users in the form of prepackaged KML network link documents.
What is a KML network link, and how does it work with map, geocode, geoprocessing, or 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 ArcGIS Server service as a ground overlay, that is, as an image draped on to the surface of the globe. If the service is a cached map service in a supported coordinate system (WGS84, WGS 1984 Web Mercator, or any other cylindrical projection), then the ground overlay is also returned using Regions. Regions expose a hierarchical collection of images and are recommended for optimum performance. Note that ArcGIS Server image services cannot be fully cached and therefore cannot be shared using Regions.
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 return 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 the Services Directory, through Manager, 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 for more details on this authoring process.
How can you find the URL for a particular service?
The REST URLs are easily found using the ArcGIS Services Directory. The Services Directory is an application included with ArcGIS Server that helps you navigate REST-related information about your services, including URLs. Open the Services Directory directly from the Start menu or by opening a browser to http://<web server name>/<instance name>/rest/services. Click through the link to your service, then right-click View In: Google Earth and click Copy Shortcut to get the link.
The URLs for the default REST map service and image service endpoints are built directly from the pieces http:// <web_server_name>/ <instance_name>/rest/services/ <service_name>/ <service_type>/kml / <service>.kmz. The various names are defined by the publisher as the ArcGIS Server service is created, and the service type is either MapServer or ImageServer.
An example of a URL that connects to an ArcGIS Server service as a KML network link using REST is
- http://myServer/arcgis/rest/services/serviceName/MapServer/kml/mapImage.kmz
The MapService REST URL for generating a custom KML network link document is located on the same Services Directory page as the default MapService 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 will create 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 the Query Layer operation, opens the query layer page.
Choosing KML as the format will create a network link URL that you can paste in a Network Link document:
http://myServer/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 the Map Service Properties dialog box in ArcCatalog and look up the URL to the non-REST KMLService directly on the Capabilities tab. This URL can be used for building custom KML network links by hand in a KML client.
When constructing a custom KML network link using Manager, the KMZ file is automatically copied to your virtual root directory and is available at http://<web server name>/ <instance name>/kml for everyone to access. Simply open this location in a browser to view all the custom KML Network Links for your server.
Once you have the URL to the KML network link document, publish it on your Web site or some other public area so others can open the KML quickly and easily.