Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Access by calling const {Data} = await google.maps.importLibrary("maps"). See https://developers.google.com/maps/documentation/javascript/libraries.

Hierarchy

Index

Constructors

Methods

  • 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.

    Parameters

    Returns google.maps.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.

    Parameters

    Returns google.maps.Data.Feature[]

  • 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.

    Parameters

    • eventName: string
    • handler: Function

    Returns MapsEventListener

  • bindTo(key: string, target: MVCObject, targetKey?: null | string, noNotify?: boolean): void
  • Binds a View to a Model.

    Parameters

    • key: string
    • target: MVCObject
    • Optional targetKey: null | string
    • Optional noNotify: boolean

    Returns void

  • Checks whether the given feature is in the collection.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns void

  • get(key: string): any
  • Gets a value.

    Parameters

    • key: string

    Returns any

  • Returns the position of the drawing controls on the map.

    Returns ControlPosition

  • getControls(): null | string[]
  • 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 null | string[]

  • getDrawingMode(): null | string
  • 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 null | string

  • 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.

    Parameters

    • id: string | number

    Returns undefined | google.maps.Data.Feature

  • getMap(): null | Map
  • Returns the map on which the features are displayed.

    Returns null | Map

  • 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().

    Parameters

    Returns void

  • notify(key: string): void
  • 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.

    Parameters

    • key: string

    Returns void

  • 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().

    Parameters

    Returns void

  • 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.

    Parameters

    Returns void

  • set(key: string, value: unknown): void
  • Sets a value.

    Parameters

    • key: string
    • value: unknown

    Returns void

  • Sets the position of the drawing controls on the map.

    Parameters

    Returns void

  • setControls(controls: null | string[]): void
  • 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".

    Parameters

    • controls: null | string[]

    Returns void

  • setDrawingMode(drawingMode: null | string): void
  • 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".

    Parameters

    • drawingMode: null | string

    Returns void

  • setMap(map: null | Map): void
  • Renders the features on the specified map. If map is set to null, the features will be removed from the map.

    Parameters

    • map: null | Map

    Returns void

  • 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.

    Parameters

    Returns void

  • setValues(values?: null | object): void
  • Sets a collection of key-value pairs.

    Parameters

    • Optional values: null | object

    Returns void

  • toGeoJson(callback: ((a: object) => void)): void
  • Exports the features in the collection to a GeoJSON object.

    Parameters

    • callback: ((a: object) => void)
        • (a: object): void
        • Parameters

          • a: object

          Returns void

    Returns void

  • unbind(key: string): void
  • 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.

    Parameters

    • key: string

    Returns void

  • unbindAll(): void

Generated using TypeDoc