Data

Data class

google.maps.Data class

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.

This class extends MVCObject.

Access by calling const {Data} = await google.maps.importLibrary("maps").
See Libraries in the Maps JavaScript API.

Data
Data([options])
Parameters: 
Creates an empty collection, with the given DataOptions.
add
add([feature])
Parameters: 
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: 
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: 
Return Value:  boolean
Checks whether the given feature is in the collection.
forEach
forEach(callback)
Parameters: 
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
Returns the position of the drawing controls on the map.