KML
KmlLayer class
google.maps.KmlLayer
class
A KmlLayer adds geographic markup to the map from a KML, KMZ or GeoRSS file that is hosted on a publicly accessible web server. A KmlFeatureData object is provided for each feature when clicked.
This class extends
MVCObject.
Access by calling const {KmlLayer} = await google.maps.importLibrary("maps").
See Libraries in the Maps JavaScript API.
Constructor | |
|---|---|
KmlLayer |
Parameters:
Creates a |
Methods | |
|---|---|
getDefaultViewport |
Parameters: None Return Value: Get the default viewport for the layer being displayed. |
getMap |
Parameters: None Return Value: Get the map on which the KML Layer is being rendered. |
getMetadata |
Parameters: None Return Value: Get the metadata associated with this layer, as specified in the layer markup. |
getStatus |
Parameters: None Return Value: Get the status of the layer, set once the requested document has loaded. |
getUrl |
Parameters: None Return Value: Gets the URL of the KML file being displayed. |
getZIndex |
Parameters: None Return Value: Gets the z-index of the KML Layer. |
setMap |
Parameters:
Return Value: None Renders the KML Layer on the specified map. If map is set to |
setOptions |
Parameters:
Return Value: None |
setUrl |
Parameters:
Return Value: None Sets the URL of the KML file to display. |
setZIndex |
Parameters:
Return Value: None Sets the z-index of the KML Layer. |
Inherited:
addListener,
bindTo,
get,
notify,
set,
setValues,
unbind,
unbindAll
| |
Events | |
|---|---|
click |
Arguments:
This event is fired when a feature in the layer is clicked. |
defaultviewport_changed |
Arguments: None This event is fired when the KML layers default viewport has changed. |
status_changed |
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 interface
google.maps.KmlLayerOptions
interface
This object defines the properties that can be set on a KmlLayer object.
Properties | |
|---|---|
clickable optional |
Type: Default: If |
map optional |
Type: The map on which to display the layer. |
preserveViewport optional |
Type: Default: If this option is set to |
screenOverlays optional |
Type: Default: Whether to render the screen overlays. |
suppressInfoWindows optional |
Type: Suppress the rendering of info windows when layer features are clicked. |
url optional |
Type: The URL of the KML document to display. |
zIndex optional |
Type: The z-index of the layer. |
google.maps.KmlLayerMetadata
interface
Metadata for a single KML layer, in JSON format.
Properties | |
|---|---|
description |
Type: The layer's |
hasScreenOverlays |
Type: Whether the layer has any screen overlays. |
name |
Type: The layer's |
snippet |
Type: The layer's |
author optional |
Type: The layer's |
KmlLayerStatus constants
google.maps.KmlLayerStatus
constants
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.
Access by calling const {KmlLayerStatus} = await google.maps.importLibrary("maps").
See Libraries in the Maps JavaScript API.
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 interface
google.maps.KmlMouseEvent
interface
The properties of a click event on a KML/KMZ or GeoRSS document.
Properties | |
|---|---|
featureData |
Type: A |
latLng |
Type: The position at which to anchor an infowindow on the clicked feature. |
pixelOffset |
Type: The offset to apply to an infowindow anchored on the clicked feature. |
KmlFeatureData interface
google.maps.KmlFeatureData
interface
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: The feature's |
description |
Type: The feature's |
id |
Type: The feature's |
infoWindowHtml |
Type: The feature's balloon styled text, if set. |
name |
Type: The feature's |
snippet |
Type: The feature's |
google.maps.KmlAuthor
interface
Contains details of the author of a KML document or feature.
Properties | |
|---|---|
email |
Type: The author's e-mail address, or an empty string if not specified. |
name |
Type: The author's name, or an empty string if not specified. |
uri |
Type: The author's home page, or an empty string if not specified. |