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(...);
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.
Constructor | |
---|---|
Data |
Data([options]) Parameters:
Creates an empty collection, with the given DataOptions . |
Methods | |
---|---|
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 Note that the IDs |
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. |
|