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

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


class
`google.maps.Data`
extends `MVCObject`

library `"maps"`

A layer for displaying geospatial data. Points, line-strings and polygons can be displayed.

Every `Map` has a `Data` object by default, so most of the time there is no need to construct one. For example:

```
 var myMap = new google.maps.Map(...);
 myMap.data.addGeoJson(...);
 myMap.data.setStyle(...); 
```
The `Data` object is a collection of [`Features`](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.Feature).

<br />

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

| ### Constructor ||
|---|---|
| `Data` | `Data([options])` **Parameters:** - `options: Data.DataOptions optional` Creates an empty collection, with the given `DataOptions`. |

| ### Methods ||
|---|---|
| `add` | `add([feature])` **Parameters:** - `feature: Data.Feature|Data.FeatureOptions optional` **Return Value:** `Data.Feature` Adds a feature to the collection, and returns the added feature. If the feature has an ID, it will replace any existing feature in the collection with the same ID. If no feature is given, a new feature will be created with null geometry and no properties. If `FeatureOptions` are given, a new feature will be created with the specified properties. Note that the IDs `1234` and `'1234'` are equivalent. Adding a feature with ID `1234` will replace a feature with ID `'1234'`, and vice versa. |
| `addGeoJson` | `addGeoJson(geoJson[, options])` **Parameters:** - `geoJson: Object` - `options: Data.GeoJsonOptions optional` **Return Value:** `Array<Data.Feature>` Adds GeoJSON features to the collection. Give this method a parsed JSON. The imported features are returned. Throws an exception if the GeoJSON could not be imported. |
| `contains` | `contains(feature)` **Parameters:** - `feature: Data.Feature` **Return Value:** `boolean` Checks whether the given feature is in the collection. |
| `forEach` | `forEach(callback)` **Parameters:** - `callback: function(Data.Feature): void` **Return Value:** None Repeatedly invokes the given function, passing a feature in the collection to the function on each invocation. The order of iteration through the features is undefined. |
| `getControlPosition` | `getControlPosition()` **Parameters:** None **Return Value:** `ControlPosition|null` Returns the position of the drawing controls on the map. |
| `getControls` | `getControls()` **Parameters:** None **Return Value:** `Array<string>|null` Returns which drawing modes are available for the user to select, in the order they are displayed. This does not include the `null` drawing mode, which is added by default. Possible drawing modes are `"Point"`, `"LineString"` or `"Polygon"`. |
| `getDrawingMode` | `getDrawingMode()` **Parameters:** None **Return Value:** `string|null` Returns the current drawing mode of the given Data layer. A drawing mode of `null` means that the user can interact with the map as normal, and clicks do not draw anything. Possible drawing modes are `null`, `"Point"`, `"LineString"` or `"Polygon"`. |
| `getFeatureById` | `getFeatureById(id)` **Parameters:** - `id: number|string` **Return Value:** `Data.Feature|undefined` Returns the feature with the given ID, if it exists in the collection. Otherwise returns `undefined`. Note that the IDs `1234` and `'1234'` are equivalent. Either can be used to look up the same feature. |
| `getMap` | `getMap()` **Parameters:** None **Return Value:** `Map|null` Returns the map on which the features are displayed. |
| `getStyle` | `getStyle()` **Parameters:** None **Return Value:** `Data.StylingFunction|Data.StyleOptions|null` Gets the style for all features in the collection. |
| `loadGeoJson` | `loadGeoJson(url[, options, callback])` **Parameters:** - `url: string` - `options: Data.GeoJsonOptions optional` - `callback: function(Array<Data.Feature>): void optional` **Return Value:** None Loads GeoJSON from a URL, and adds the features to the collection. NOTE: The GeoJSON is fetched using XHR, and may not work cross-domain. If you have issues, we recommend you fetch the GeoJSON using your choice of AJAX library, and then call `addGeoJson()`. |
| `overrideStyle` | `overrideStyle(feature, style)` **Parameters:** - `feature: Data.Feature` - `style: Data.StyleOptions` **Return Value:** None Changes the style of a feature. These changes are applied on top of the style specified by `setStyle()`. Style properties set to `null` revert to the value specified via `setStyle()`. |
| `remove` | `remove(feature)` **Parameters:** - `feature: Data.Feature` **Return Value:** None Removes a feature from the collection. |
| `revertStyle` | `revertStyle([feature])` **Parameters:** - `feature: Data.Feature optional` **Return Value:** None Removes the effect of previous `overrideStyle()` calls. The style of the given feature reverts to the style specified by `setStyle()`. If no feature is given, all features have their style reverted. |
| `setControlPosition` | `setControlPosition(controlPosition)` **Parameters:** - `controlPosition: ControlPosition optional` **Return Value:** None Sets the position of the drawing controls on the map. |
| `setControls` | `setControls(controls)` **Parameters:** - `controls: Array<string> optional` **Return Value:** None Sets which drawing modes are available for the user to select, in the order they are displayed. This should not include the `null` drawing mode, which is added by default. If `null`, drawing controls are disabled and not displayed. Possible drawing modes are `"Point"`, `"LineString"` or `"Polygon"`. |
| `setDrawingMode` | `setDrawingMode(drawingMode)` **Parameters:** - `drawingMode: string optional` **Return Value:** None Sets the current drawing mode of the given Data layer. A drawing mode of `null` means that the user can interact with the map as normal, and clicks do not draw anything. Possible drawing modes are `null`, `"Point"`, `"LineString"` or `"Polygon"`. |
| `setMap` | `setMap(map)` **Parameters:** - `map: Map optional` **Return Value:** None Renders the features on the specified map. If map is set to `null`, the features will be removed from the map. |
| `setStyle` | `setStyle(style)` **Parameters:** - `style: Data.StylingFunction|Data.StyleOptions optional` **Return Value:** None Sets the style for all features in the collection. Styles specified on a per-feature basis via `overrideStyle()` continue to apply. Pass either an object with the desired style options, or a function that computes the style for each feature. The function will be called every time a feature's properties are updated. |
| `toGeoJson` | `toGeoJson(callback)` **Parameters:** - `callback: function(Object): void` **Return Value:** None Exports the features in the collection to a GeoJSON object. |

| ### Events ||
|---|---|
| `addfeature` | `function(event)` **Arguments:** - `event: Data.AddFeatureEvent optional` This event is fired when a feature is added to the collection. |
| `click` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired for a click on the geometry. |
| `contextmenu` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired when the DOM contextmenu event is fired on the geometry. |
| `dblclick` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired for a double click on the geometry. |
| `mousedown` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired for a mousedown on the geometry. |
| `mouseout` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired when the mouse leaves the area of the geometry. |
| `mouseover` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired when the mouse enters the area of the geometry. |
| `mouseup` | `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired for a mouseup on the geometry. |
| `removefeature` | `function(event)` **Arguments:** - `event: Data.RemoveFeatureEvent optional` This event is fired when a feature is removed from the collection. |
| `removeproperty` | `function(event)` **Arguments:** - `event: Data.RemovePropertyEvent optional` This event is fired when a feature's property is removed. |
| `setgeometry` | `function(event)` **Arguments:** - `event: Data.SetGeometryEvent optional` This event is fired when a feature's geometry is set. |
| `setproperty` | `function(event)` **Arguments:** - `event: Data.SetPropertyEvent optional` This event is fired when a feature's property is set. |
| `[rightclick](https://developers.google.com/maps/documentation/javascript/reference/data#Data.rightclick)` | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** Use the `Data.contextmenu` event instead in order to support usage patterns like control-click on macOS. `function(event)` **Arguments:** - `event: Data.MouseEvent optional` This event is fired for a rightclick on the geometry. |

## [Data.DataOptions](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.DataOptions)
interface


interface
`google.maps.Data.DataOptions`

DataOptions object used to define the properties that a developer can set on a `Data` object.

| ### Properties ||
|---|---|
| `map` | **Type:** `Map` Map on which to display the features in the collection. |
| `controlPosition` optional | **Type:** `ControlPosition optional` **Default:** `ControlPosition.TOP_LEFT` The position of the drawing controls on the map. |
| `controls` optional | **Type:** `Array<string> optional` **Default:** `null` Describes which drawing modes are available for the user to select, in the order they are displayed. This should not include the `null` drawing mode, which is added by default. If `null`, drawing controls are disabled and not displayed. Possible drawing modes are `"Point"`, `"LineString"` or `"Polygon"`. |
| `drawingMode` optional | **Type:** `string optional` **Default:** `null` The current drawing mode of the given Data layer. A drawing mode of `null` means that the user can interact with the map as normal, and clicks do not draw anything. Possible drawing modes are `null`, `"Point"`, `"LineString"` or `"Polygon"`. |
| `featureFactory` optional | **Type:** `function(Data.Geometry): Data.Feature optional` When drawing is enabled and a user draws a Geometry (a Point, Line String or Polygon), this function is called with that Geometry and should return a Feature that is to be added to the Data layer. If a featureFactory is not supplied, a Feature with no id and no properties will be created from that Geometry instead. Defaults to `null`. |
| `style` optional | **Type:** `Data.StylingFunction|Data.StyleOptions optional` Style for all features in the collection. For more details, see the `setStyle()` method above. |

## [Data.GeoJsonOptions](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.GeoJsonOptions)
interface


interface
`google.maps.Data.GeoJsonOptions`

Optional parameters for importing GeoJSON.

| ### Properties ||
|---|---|
| `idPropertyName` optional | **Type:** `string optional` The name of the Feature property to use as the feature ID. If not specified, the GeoJSON Feature id will be used. |

## [Data.StyleOptions](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.StyleOptions)
interface


interface
`google.maps.Data.StyleOptions`

These options specify the way a Feature should appear when displayed on a map.

| ### Properties ||
|---|---|
| `animation` optional | **Type:** `Animation optional` The animation to play when marker is added to a map. Only applies to point geometries. |
| `clickable` optional | **Type:** `boolean optional` **Default:** `true` If `true`, the marker receives mouse and touch events. |
| `cursor` optional | **Type:** `string optional` Mouse cursor to show on hover. Only applies to point geometries. |
| `draggable` optional | **Type:** `boolean optional` **Default:** `false` If `true`, the object can be dragged across the map and the underlying feature will have its geometry updated. |
| `editable` optional | **Type:** `boolean optional` **Default:** `false` If `true`, the object can be edited by dragging control points and the underlying feature will have its geometry updated. Only applies to LineString and Polygon geometries. |
| `fillColor` optional | **Type:** `string optional` The fill color. All CSS3 colors are supported except for extended named colors. Only applies to polygon geometries. |
| `fillOpacity` optional | **Type:** `number optional` The fill opacity between 0.0 and 1.0. Only applies to polygon geometries. |
| `icon` optional | **Type:** `string|Icon|Symbol optional` Icon for the foreground. If a string is provided, it is treated as though it were an `Icon` with the string as `url`. Only applies to point geometries. |
| `icons` optional | **Type:** `Array<IconSequence> optional` The icons to be rendered along a polyline. Only applies to line geometries. |
| `label` optional | **Type:** `string|MarkerLabel optional` Adds a label to the marker. The label can either be a string, or a `MarkerLabel` object. Only applies to point geometries. |
| `opacity` optional | **Type:** `number optional` The marker's opacity between 0.0 and 1.0. Only applies to point geometries. |
| `shape` optional | **Type:** `MarkerShape optional` Defines the image map used for hit detection. Only applies to point geometries. |
| `strokeColor` optional | **Type:** `string optional` The stroke color. All CSS3 colors are supported except for extended named colors. Only applies to line and polygon geometries. |
| `strokeOpacity` optional | **Type:** `number optional` The stroke opacity between 0.0 and 1.0. Only applies to line and polygon geometries. |
| `strokeWeight` optional | **Type:** `number optional` The stroke width in pixels. Only applies to line and polygon geometries. |
| `title` optional | **Type:** `string optional` Rollover text. Only applies to point geometries. |
| `visible` optional | **Type:** `boolean optional` **Default:** `true` Whether the feature is visible. |
| `zIndex` optional | **Type:** `number optional` All features are displayed on the map in order of their zIndex, with higher values displaying in front of features with lower values. Markers are always displayed in front of line-strings and polygons. |

## [Data.StylingFunction](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.StylingFunction)
typedef


typedef
`google.maps.Data.StylingFunction`

A function that computes the appearance of a feature.

The `Data.setStyle()` method can accept a styling function. Use this when features should appear differently depending on their properties. You can find more information about styling features in the [developer's guide](https://developers.google.com/maps/documentation/javascript/datalayer.md.txt#style_geojson_data).

`function(Data.Feature): Data.StyleOptions`

## [Data.Feature](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.Feature)
class


class
`google.maps.Data.Feature`

library `"maps"`

A feature has a geometry, an id, and a set of properties.

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

| ### Constructor ||
|---|---|
| `Data.Feature` | `Data.Feature([options])` **Parameters:** - `options: Data.FeatureOptions optional` Constructs a Feature with the given options. |

| ### Methods ||
|---|---|
| `forEachProperty` | `forEachProperty(callback)` **Parameters:** - `callback: function(*, string): void` **Return Value:** None Repeatedly invokes the given function, passing a property value and name on each invocation. The order of iteration through the properties is undefined. |
| `getGeometry` | `getGeometry()` **Parameters:** None **Return Value:** `Data.Geometry|null` Returns the feature's geometry. |
| `getId` | `getId()` **Parameters:** None **Return Value:** `number|string|undefined` Returns the feature ID. |
| `getProperty` | `getProperty(name)` **Parameters:** - `name: string` **Return Value:** `*` Returns the value of the requested property, or `undefined` if the property does not exist. |
| `removeProperty` | `removeProperty(name)` **Parameters:** - `name: string` **Return Value:** None Removes the property with the given name. |
| `setGeometry` | `setGeometry(newGeometry)` **Parameters:** - `newGeometry: Data.Geometry|LatLng|LatLngLiteral optional` **Return Value:** None Sets the feature's geometry. |
| `setProperty` | `setProperty(name, newValue)` **Parameters:** - `name: string` - `newValue: *` **Return Value:** None Sets the value of the specified property. If `newValue` is `undefined` this is equivalent to calling `removeProperty`. |
| `toGeoJson` | `toGeoJson(callback)` **Parameters:** - `callback: function(Object): void` **Return Value:** None Exports the feature to a GeoJSON object. |

| ### Events ||
|---|---|
| `removeproperty` | `function(event)` **Arguments:** - `event: Data.RemovePropertyEvent` This event is triggered when a feature's property is removed. |
| `setgeometry` | `function(event)` **Arguments:** - `event: Data.SetGeometryEvent` This event is triggered when a feature's geometry is set. |
| `setproperty` | `function(event)` **Arguments:** - `event: Data.SetPropertyEvent` This event is triggered when a feature's property is set. |

## [Data.FeatureOptions](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.FeatureOptions)
interface


interface
`google.maps.Data.FeatureOptions`

Optional parameters for creating `Data.Feature` objects.

| ### Properties ||
|---|---|
| `geometry` optional | **Type:** `Data.Geometry|LatLng|LatLngLiteral optional` The feature geometry. If none is specified when a feature is constructed, the feature's geometry will be `null`. If a `LatLng` object or `LatLngLiteral` is given, this will be converted to a `Data.Point` geometry. |
| `id` optional | **Type:** `number|string optional` Feature ID is optional. If provided, it can be used to look up the feature in a `Data` object using the `getFeatureById()` method. Note that a feature's ID cannot be subsequently changed. |
| `properties` optional | **Type:** `Object optional` The feature properties. This is an arbitrary mapping of property names to values. |

## [Data.Geometry](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.Geometry)
interface


interface
`google.maps.Data.Geometry`

implemented by `Data.GeometryCollection, Data.LinearRing, Data.LineString, Data.MultiLineString, Data.MultiPoint, Data.MultiPolygon, Data.Point, Data.Polygon`

A superclass for the various geometry objects.

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** `void` Repeatedly invokes the given function, passing a point from the geometry to the function on each invocation. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the type of the geometry object. Possibilities are `"Point"`, `"MultiPoint"`, `"LineString"`, `"MultiLineString"`, `"LinearRing"`, `"Polygon"`, `"MultiPolygon"`, or `"GeometryCollection"`. |

## [Data.Point](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.Point)
class


class
`google.maps.Data.Point`
implements `Data.Geometry`

library `"maps"`

A Point geometry contains a single `LatLng`.

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

| ### Constructor ||
|---|---|
| `Data.Point` | `Data.Point(latLng)` **Parameters:** - `latLng: LatLng|LatLngLiteral` Constructs a `Data.Point` from the given `LatLng` or `LatLngLiteral`. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `get` | `get()` **Parameters:** None **Return Value:** `LatLng` Returns the contained `LatLng`. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"Point"`. |

## [Data.MultiPoint](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.MultiPoint)
class


class
`google.maps.Data.MultiPoint`
implements `Data.Geometry`

library `"maps"`

A MultiPoint geometry contains a number of `LatLng`s.

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

| ### Constructor ||
|---|---|
| `Data.MultiPoint` | `Data.MultiPoint(elements)` **Parameters:** - `elements: Array<LatLng|LatLngLiteral>` Constructs a `Data.MultiPoint` from the given `LatLng`s or `LatLngLiteral`s. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<LatLng>` Returns an array of the contained `LatLng`s. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `LatLng` Returns the `n`-th contained `LatLng`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `LatLng`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"MultiPoint"`. |

## [Data.LineString](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.LineString)
class


class
`google.maps.Data.LineString`
implements `Data.Geometry`

library `"maps"`

A LineString geometry contains a number of `LatLng`s.

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

| ### Constructor ||
|---|---|
| `Data.LineString` | `Data.LineString(elements)` **Parameters:** - `elements: Array<LatLng|LatLngLiteral>` Constructs a `Data.LineString` from the given `LatLng`s or `LatLngLiteral`s. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<LatLng>` Returns an array of the contained `LatLngs`. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `LatLng` Returns the `n`-th contained `LatLng`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `LatLng`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"LineString"`. |

## [Data.MultiLineString](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.MultiLineString)
class


class
`google.maps.Data.MultiLineString`
implements `Data.Geometry`

library `"maps"`

A MultiLineString geometry contains a number of `LineString`s.

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

| ### Constructor ||
|---|---|
| `Data.MultiLineString` | `Data.MultiLineString(elements)` **Parameters:** - `elements: Array<Data.LineString|Array<LatLng|LatLngLiteral>>` Constructs a `Data.MultiLineString` from the given `Data.LineString`s or arrays of positions. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<Data.LineString>` Returns an array of the contained `Data.LineString`s. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `Data.LineString` Returns the `n`-th contained `Data.LineString`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `Data.LineString`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"MultiLineString"`. |

## [Data.LinearRing](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.LinearRing)
class


class
`google.maps.Data.LinearRing`
implements `Data.Geometry`

library `"maps"`

A LinearRing geometry contains a number of `LatLng`s, representing a closed LineString. There is no need to make the first `LatLng` equal to the last `LatLng`. The LinearRing is closed implicitly.

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

| ### Constructor ||
|---|---|
| `Data.LinearRing` | `Data.LinearRing(elements)` **Parameters:** - `elements: Array<LatLng|LatLngLiteral>` Constructs a `Data.LinearRing` from the given `LatLng`s or `LatLngLiteral`s. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<LatLng>` Returns an array of the contained `LatLng`s. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `LatLng` Returns the `n`-th contained `LatLng`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `LatLng`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"LinearRing"`. |

## [Data.Polygon](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.Polygon)
class


class
`google.maps.Data.Polygon`
implements `Data.Geometry`

library `"maps"`

A Polygon geometry contains a number of `Data.LinearRing`s. The first linear-ring must be the polygon exterior boundary and subsequent linear-rings must be interior boundaries, also known as holes. See the [sample polygon with a hole](https://developers.google.com/maps/documentation/javascript/examples/layer-data-polygon.md.txt).

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

| ### Constructor ||
|---|---|
| `Data.Polygon` | `Data.Polygon(elements)` **Parameters:** - `elements: Array<Data.LinearRing|Array<LatLng|LatLngLiteral>>` Constructs a `Data.Polygon` from the given `Data.LinearRing`s or arrays of positions. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<Data.LinearRing>` Returns an array of the contained `Data.LinearRing`s. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `Data.LinearRing` Returns the `n`-th contained `Data.LinearRing`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `Data.LinearRing`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"Polygon"`. |

## [Data.MultiPolygon](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.MultiPolygon)
class


class
`google.maps.Data.MultiPolygon`
implements `Data.Geometry`

library `"maps"`

A MultiPolygon geometry contains a number of `Data.Polygon`s.

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

| ### Constructor ||
|---|---|
| `Data.MultiPolygon` | `Data.MultiPolygon(elements)` **Parameters:** - `elements: Array<Data.Polygon|Array<Data.LinearRing|Array<LatLng|LatLngLiteral>>>` Constructs a `Data.MultiPolygon` from the given `Data.Polygon`s or arrays of positions. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<Data.Polygon>` Returns an array of the contained `Data.Polygon`s. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `Data.Polygon` Returns the `n`-th contained `Data.Polygon`. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained `Data.Polygon`s. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"MultiPolygon"`. |

## [Data.GeometryCollection](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.GeometryCollection)
class


class
`google.maps.Data.GeometryCollection`
implements `Data.Geometry`

library `"maps"`

A GeometryCollection contains a number of geometry objects. Any `LatLng` or `LatLngLiteral` objects are automatically converted to `Data.Point` geometry objects.

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

| ### Constructor ||
|---|---|
| `Data.GeometryCollection` | `Data.GeometryCollection(elements)` **Parameters:** - `elements: Array<Data.Geometry|LatLng|LatLngLiteral>` Constructs a `Data.GeometryCollection` from the given geometry objects or `LatLng`s. |

| ### Methods ||
|---|---|
| `forEachLatLng` | `forEachLatLng(callback)` **Parameters:** - `callback: function(LatLng): void` **Return Value:** None |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<Data.Geometry>` Returns an array of the contained geometry objects. A new array is returned each time `getArray()` is called. |
| `getAt` | `getAt(n)` **Parameters:** - `n: number` **Return Value:** `Data.Geometry` Returns the `n`-th contained geometry object. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of contained geometry objects. |
| `getType` | `getType()` **Parameters:** None **Return Value:** `string` Returns the string `"GeometryCollection"`. |

## [Data.MouseEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.MouseEvent)
interface


interface
`google.maps.Data.MouseEvent`
extends `MapMouseEvent`

This object is passed to mouse event handlers on a `Data` object.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature which generated the mouse event. |

| ### Methods ||
|---|---|

## [Data.AddFeatureEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.AddFeatureEvent)
interface


interface
`google.maps.Data.AddFeatureEvent`

The properties of a `addfeature` event.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature that was added to the `FeatureCollection`. |

## [Data.RemoveFeatureEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.RemoveFeatureEvent)
interface


interface
`google.maps.Data.RemoveFeatureEvent`

The properties of a `removefeature` event.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature that was removed from the `FeatureCollection`. |

## [Data.SetGeometryEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.SetGeometryEvent)
interface


interface
`google.maps.Data.SetGeometryEvent`

The properties of a `setgeometry` event.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature whose geometry was set. |
| `newGeometry` optional | **Type:** `Data.Geometry optional` The new feature geometry. |
| `oldGeometry` optional | **Type:** `Data.Geometry optional` The previous feature geometry. |

## [Data.SetPropertyEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.SetPropertyEvent)
interface


interface
`google.maps.Data.SetPropertyEvent`

The properties of a `setproperty` event.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature whose property was set. |
| `name` | **Type:** `string` The property name. |
| `newValue` | **Type:** `*` The new value. |
| `oldValue` | **Type:** `*` The previous value. Will be `undefined` if the property was added. |

## [Data.RemovePropertyEvent](https://developers.google.com/maps/documentation/javascript/reference/data.md.txt#Data.RemovePropertyEvent)
interface


interface
`google.maps.Data.RemovePropertyEvent`

The properties of a `removeproperty` event.

| ### Properties ||
|---|---|
| `feature` | **Type:** `Data.Feature` The feature whose property was removed. |
| `name` | **Type:** `string` The property name. |
| `oldValue` | **Type:** `*` The previous value. |