Keyhole Markup Language (KML), is an Extensible Markup Language (XML) grammar and file format for modeling and storing geographic features, including geometric shapes, symbology, and attributes. KML was originally created to view features in three-dimensional (3D) Earth browsers such as Google Earth but is supported in a number of two-dimensional (2D) clients including ArcGIS Runtime SDK for Java applications.

Displaying KML

This section assumes you can create a simple mapping application using the ArcGIS Runtime SDK for Java, for example using the Eclipse plugin as described in the topic Creating a simple Java map application. In order to display a KML file in your map, create a KMLLayer and add it to your map's layer list. The recommended workflow is to first add a basemap to your map's layer list, then to create the KMLLayer using the URL of the KML file and the spatial reference of the basemap used, as in the code snippet below:

JMap map = new JMap();
LayerList layers = map.getLayers();
// add a tiled layer basemap
final ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer(
// add KML layer from publicly accessible URL and tiled layer's spatial reference
final KMLLayer kmlLayer = new KMLLayer(

To add a KML file (.kml or .kmz extension) to a map, the KML must be available via a publicly accessible URL. Locally hosted files or KML files inside a firewall are not supported.