Tutorial: Publishing a KML service

Release 9.3.1 E-mail This Topic Printable Version Give Us Feedback

You can serve KML dynamically over the Web by publishing an ArcMap document (.mxd) as an ArcGIS Server map service. The map service has a KML capability enabled, which allows a client to connect to the map service and request KML data for a specific geographic area. The KML can be exposed through a KML network link document that embeds a properly configured URL to the service.

This tutorial walks you through the process of creating a KML service with 3D extruded features. You'll first create the map in ArcMap, using ArcGlobe to set some of the 3D extrusion properties. Then, you'll publish the map as a service with the KML capability enabled. Finally, you'll create a KML network link on your server so that others can easily access the KML.

Preparing the data in ArcGlobe and ArcMap

To publish feature classes with 3D attributes such as z-offsets or extrusion based on attributes, you must first edit the feature class layer properties in ArcGlobe and save them as a layer file, then add the layer file to an ArcMap document. For example, if you have a polygon feature class with a population density attribute, you can set the extrusion properties for that class in ArcGlobe, save the feature class as a layer file, then add the layer file to an ArcMap document (you can also configure extrusion and export a layer file in ArcScene if you do not have ArcGlobe available).

  1. Start ArcGlobe and add a feature class.

  2. Open the layer properties by right-clicking the layer name and choosing Properties.

  3. Click the Globe Extrusion tab on the Layer Properties dialog box.

  4. Select "Extrude features in layer" and "Do not draw bottom face of extruded polygons".

  5. Set an Extrusion value or expression. In this case, the polygon features are extruded by multiplying the value of the POP_DENSITY attribute by 100 and adding this value to the feature base height.

  6. Now that the extrusion is set for the layer, right-click the layer and choose "Save As Layer File" from the context menu.

  7. Now that 3D properties have been determined for the data, it's time to start ArcMap and set the 2D layer properties.

  8. In ArcMap, add the layer just saved from ArcGlobe.

  9. Set the 2D layer properties by right-clicking the layer and choosing Properties from the context menu.

  10. Click the General tab, edit the scale dependency of the layer then enter a description. This description will be used for the KML layer description displayed in KML clients and can contain any valid HTML.

  11. Click the Display tab and alter the transparency of the layer if you want.

  12. Click the Symbology tab and change the rendering properties.

  13. Click the Fields tab and alter the Primary Display Field if you want. This field value will be used to label the features in the table of contents. You can also use two reserved aliases, KMLDescription and KMLSnippet, in any two fields in the feature class. The values of the field that you change to use the KMLDescription alias will be displayed when a user clicks a feature in the table of contents of a KML client. The values of the KMLDescription alias field can contain any valid HTML. The values of the field that you change to use the KMLSnippet alias will be displayed below each feature's icon in the table of contents of a KML client. The values of the KMLSnippet alias field can also contain any valid HTML.



Publishing the KML service

Once the 2D and 3D properties of an ArcMap document have been set, you need to follow only a few simple publishing steps to create a KML service. Follow the same procedure used to create an ArcGIS Server map service. By default, the KML capability is enabled on the map service. The steps below show how to do this in ArcCatalog. If you want to use Manager to create the service, follow the corresponding steps in Publishing a GIS resource to the server.

  1. Using ArcCatalog, find the ArcMap Document you want to publish in the file system.

  2. Right-click the ArcMap document (.mxd) and choose Publish to ArcGIS Server from the context menu.

  3. Choose an existing folder (or create a new one) in which to publish your KML-capable GIS service.

  4. On the second Publish to ArcGIS Server wizard page, notice that the KML capability is enabled. Leave it checked and click Next.

  5. Review the summary of what will be created in the third Publish to ArcGIS Server wizard page and click Publish.

  6. Your service has now been published and can be previewed in ArcCatalog by expanding the GIS Servers node and the folder in which you published your service, then choosing your service and clicking the Preview tab in the adjacent panel.



Configuring properties for the KML service

After publishing the KML service, you may want to edit its default properties. To do this, follow the steps below:

  1. First stop the service in ArcCatalog by right-clicking the service name and choosing Stop from the context menu.

  2. Next, right-click the service name and choose Service Properties from the context menu.

  3. Click the Capabilities tab in the map service Properties dialog box.

  4. Click KML (be careful not to uncheck the box) and edit the Properties in the lower panel.

  5. Restart the service by right-clicking the service name and choosing Start from the context menu.

Publishing a network link

You can make the KML available on your server in an easily consumable format by publishing a KML network link. You'll publish the network link in Manager. Then you can add the network link in ArcGIS Explorer or Google Earth.

  1. Log in to ArcGIS Server Manager.
  2. Click the Applications tab and click KML Network Links.
  3. Click Create Network Link.
  4. Type a name and, optionally, short and long descriptions for your KML. Then click Next.
  5. In the Map Service drop-down list, find the map service you just published. Uncheck any layers you do not want to expose in the network link (by default they are all visible). Then choose the option to draw "Vector layers as vectors and raster layers as images". Your extruded features are vectors, so you need to choose this option. Otherwise, you will see a "flat" rasterized image. Click Next.
  6. In this final page of the wizard, you can adjust the Refresh, View, and Hostname parameters if you want. In this tutorial, it's okay to accept the defaults.
  7. Click Finish to create the KML network link. When you return to the KML Network Links page in Manager, you will see the URL to your new network link. (For example: http://myServer/ArcGIS/kml/networklink1.kmz). Use this URL to add your KML network link to Google Earth or ArcGIS Explorer.