<iframe src="https://developers.devsite.google/frame/maps/documentation/javascript/reference/kml_78e4a0d2e9d3c454ac4c3e4546e138bee84a18b1b576d5f4b460c02bcdd37bda.frame" class="framebox inherit-locale redirect-iframe" allow="clipboard-write https://developers.devsite.google" allowfullscreen is-upgraded></iframe>

## [KmlLayer](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlLayer)
class


class
`google.maps.KmlLayer`
extends `MVCObject`

library `"maps"`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

```javascript
const {KmlLayer} = await google.maps.importLibrary("maps");
```

| ### Constructor ||
|---|---|
| `KmlLayer` | `KmlLayer([opts])` **Parameters:** - `opts: KmlLayerOptions optional` Options for this layer. Creates a `KmlLayer` which renders the contents of the specified KML/KMZ file (<https://developers.google.com/kml/documentation/kmlreference>) or GeoRSS file (<http://www.georss.org>). |

| ### Methods ||
|---|---|
| `getDefaultViewport` | `getDefaultViewport()` **Parameters:** None **Return Value:** `LatLngBounds|null` Get the default viewport for the layer being displayed. |
| `getMap` | `getMap()` **Parameters:** None **Return Value:** `Map|null` Get the map on which the KML Layer is being rendered. |
| `getMetadata` | `getMetadata()` **Parameters:** None **Return Value:** `KmlLayerMetadata|null` Get the metadata associated with this layer, as specified in the layer markup. |
| `getStatus` | `getStatus()` **Parameters:** None **Return Value:** `KmlLayerStatus|null` Get the status of the layer, set once the requested document has loaded. |
| `getUrl` | `getUrl()` **Parameters:** None **Return Value:** `string` URL Gets the URL of the KML file being displayed. |
| `getZIndex` | `getZIndex()` **Parameters:** None **Return Value:** `number` The z-index. Gets the z-index of the KML Layer. |
| `setMap` | `setMap(map)` **Parameters:** - `map: Map optional` **Return Value:** None Renders the KML Layer on the specified map. If map is set to `null`, the layer is removed. |
| `setOptions` | `setOptions(options)` **Parameters:** - `options: KmlLayerOptions optional` **Return Value:** None |
| `setUrl` | `setUrl(url)` **Parameters:** - `url: string` **Return Value:** None Sets the URL of the KML file to display. |
| `setZIndex` | `setZIndex(zIndex)` **Parameters:** - `zIndex: number` The z-index to set. **Return Value:** None Sets the z-index of the KML Layer. |

| ### Events ||
|---|---|
| `click` | `function(kmlClickEvent)` **Arguments:** - `kmlClickEvent: KmlMouseEvent` This event is fired when a feature in the layer is clicked. |
| `defaultviewport_changed` | `function()` **Arguments:** None This event is fired when the KML layers default viewport has changed. |
| `status_changed` | `function()` **Arguments:** None This event is fired when the KML layer has finished loading. At this point it is safe to read the status property to determine if the layer loaded successfully. |

## [KmlLayerOptions](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlLayerOptions)
interface


interface
`google.maps.KmlLayerOptions`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

This object defines the properties that can be set on a `KmlLayer` object.

| ### Properties ||
|---|---|
| `clickable` optional | **Type:** `boolean optional` **Default:** `true` If `true`, the layer receives mouse events. |
| `map` optional | **Type:** `Map optional` The map on which to display the layer. |
| `preserveViewport` optional | **Type:** `boolean optional` **Default:** `false` If this option is set to `true` or if the map's center and zoom were never set, the input map is centered and zoomed to the bounding box of the contents of the layer. |
| `screenOverlays` optional | **Type:** `boolean optional` **Default:** `true` Whether to render the screen overlays. |
| `suppressInfoWindows` optional | **Type:** `boolean optional` Suppress the rendering of info windows when layer features are clicked. |
| `url` optional | **Type:** `string optional` The URL of the KML document to display. |
| `zIndex` optional | **Type:** `number optional` The z-index of the layer. |

## [KmlLayerMetadata](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlLayerMetadata)
interface


interface
`google.maps.KmlLayerMetadata`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

Metadata for a single KML layer, in JSON format.

| ### Properties ||
|---|---|
| `description` | **Type:** `string` The layer's `<description>`, extracted from the layer markup. |
| `hasScreenOverlays` | **Type:** `boolean` Whether the layer has any screen overlays. |
| `name` | **Type:** `string` The layer's `<name>`, extracted from the layer markup. |
| `snippet` | **Type:** `string` The layer's `<Snippet>`, extracted from the layer markup |
| `author` optional | **Type:** `KmlAuthor optional` The layer's `<atom:author>`, extracted from the layer markup. |

## [KmlLayerStatus](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlLayerStatus)
constants


constants
`google.maps.KmlLayerStatus`

library `"maps"`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

The status returned by `KmlLayer` on the completion of loading a document. Specify these by value, or by using the constant's name. For example, `'OK'` or `google.maps.KmlLayerStatus.OK`.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `KmlLayerStatusString` type.

```javascript
const {KmlLayerStatus} = await google.maps.importLibrary("maps");
```

| ### Constants ||
|---|---|
| `DOCUMENT_NOT_FOUND` | The document could not be found. Most likely it is an invalid URL, or the document is not publicly available. |
| `DOCUMENT_TOO_LARGE` | The document exceeds the file size limits of KmlLayer. |
| `FETCH_ERROR` | The document could not be fetched. |
| `INVALID_DOCUMENT` | The document is not a valid KML, KMZ or GeoRSS document. |
| `INVALID_REQUEST` | The `KmlLayer` is invalid. |
| `LIMITS_EXCEEDED` | The document exceeds the feature limits of KmlLayer. |
| `OK` | The layer loaded successfully. |
| `TIMED_OUT` | The document could not be loaded within a reasonable amount of time. |
| `UNKNOWN` | The document failed to load for an unknown reason. |

## [KmlMouseEvent](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlMouseEvent)
interface


interface
`google.maps.KmlMouseEvent`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

The properties of a click event on a KML/KMZ or GeoRSS document.

| ### Properties ||
|---|---|
| `featureData` | **Type:** `KmlFeatureData` A `KmlFeatureData` object, containing information about the clicked feature. |
| `latLng` | **Type:** `LatLng` The position at which to anchor an infowindow on the clicked feature. |
| `pixelOffset` | **Type:** `Size` The offset to apply to an infowindow anchored on the clicked feature. |

## [KmlFeatureData](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlFeatureData)
interface


interface
`google.maps.KmlFeatureData`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

Data for a single KML feature in JSON format, returned when a KML feature is clicked. The data contained in this object mirrors that associated with the feature in the KML or GeoRSS markup in which it is declared.

| ### Properties ||
|---|---|
| `author` | **Type:** `KmlAuthor` The feature's `<atom:author>`, extracted from the layer markup (if specified). |
| `description` | **Type:** `string` The feature's `<description>`, extracted from the layer markup. |
| `id` | **Type:** `string` The feature's `<id>`, extracted from the layer markup. If no `<id>` has been specified, a unique ID will be generated for this feature. |
| `infoWindowHtml` | **Type:** `string` The feature's balloon styled text, if set. |
| `name` | **Type:** `string` The feature's `<name>`, extracted from the layer markup. |
| `snippet` | **Type:** `string` The feature's `<Snippet>`, extracted from the layer markup. |

## [KmlAuthor](https://developers.google.com/maps/documentation/javascript/reference/kml.md.txt#KmlAuthor)
interface


interface
`google.maps.KmlAuthor`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** The KmlLayer functionality in the Maps JavaScript API is no longer available in the Maps JavaScript API as of version 3.66. For more info, see <https://developers.google.com/maps/deprecations>.

Contains details of the author of a KML document or feature.

| ### Properties ||
|---|---|
| `email` | **Type:** `string` The author's e-mail address, or an empty string if not specified. |
| `name` | **Type:** `string` The author's name, or an empty string if not specified. |
| `uri` | **Type:** `string` The author's home page, or an empty string if not specified. |