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(...);The
myMap.data.addGeoJson(...);
myMap.data.setStyle(...);
Data
object is a collection of Features
.
Access by calling const {Data} = await google.maps.importLibrary("maps")
. See
https://developers.google.com/maps/documentation/javascript/libraries.
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.
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.
Adds the given listener function to the given event name. Returns an
identifier for this listener that can be used with
google.maps.event.removeListener
.
Binds a View to a Model.
Gets a value.
Returns the position of the drawing controls on the map.
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"
.
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"
.
Returns the map on which the features are displayed.
Gets the style for all features in the collection.
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()
.
Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.
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()
.
Sets a value.
Sets the position of the drawing controls on the map.
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"
.
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"
.
Renders the features on the specified map. If map is set to
null
, the features will be removed from the map.
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.
Sets a collection of key-value pairs.
Exports the features in the collection to a GeoJSON object.
Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.
Removes all bindings.
Generated using TypeDoc
A layer for displaying geospatial data. Points, line-strings and polygons can be displayed.
Every
TheMap
has aData
object by default, so most of the time there is no need to construct one. For example:Data
object is a collection ofFeatures
.Access by calling
const {Data} = await google.maps.importLibrary("maps")
. See https://developers.google.com/maps/documentation/javascript/libraries.