Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

Index

Constructors

Properties

controls: MVCArray<HTMLElement>[]

Additional controls to attach to the map. To add a control to the map, add the control's <div> to the MVCArray corresponding to the ControlPosition where it should be rendered.

An instance of Data, bound to the map. Add features to this Data object to conveniently display them on this map.

mapTypes: MapTypeRegistry

A registry of MapType instances by string ID.

overlayMapTypes: MVCArray<null | MapType>

Additional map types to overlay. Overlay map types will display on top of the base map they are attached to, in the order in which they appear in the overlayMapTypes array (overlays with higher index values are displayed in front of overlays with lower index values).

DEMO_MAP_ID: string

Map ID which can be used for code samples which require a Map ID. This Map ID is not intended for use in production applications and cannot be used for features which require cloud configuration (such as Cloud Styling).

Methods

  • 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

  • Sets the viewport to contain the given bounds.
    Note: When the map is set to display: none, the fitBounds function reads the map's size as 0x0, and therefore does not do anything. To change the viewport while the map is hidden, set the map to visibility: hidden, thereby ensuring the map div has an actual size. For vector maps, this method sets the map's tilt and heading to their default zero values. Calling this method may cause a smooth animation as the map pans and zooms to fit the bounds. Whether or not this method animates depends on an internal heuristic.

    Parameters

    • bounds: LatLngBounds | LatLngBoundsLiteral

      Bounds to show.

    • Optional padding: number | Padding

      Padding in pixels. The bounds will be fit in the part of the map that remains after padding is removed. A number value will yield the same padding on all 4 sides. Supply 0 here to make a fitBounds idempotent on the result of getBounds.

    Returns void

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

    Parameters

    • key: string

    Returns any

  • Returns the lat/lng bounds of the current viewport. If more than one copy of the world is visible, the bounds range in longitude from -180 to 180 degrees inclusive. If the map is not yet initialized or center and zoom have not been set then the result is undefined. For vector maps with non-zero tilt or heading, the returned lat/lng bounds represents the smallest bounding box that includes the visible region of the map's viewport. See google.maps.MapCanvasProjection.getVisibleRegion for getting the exact visible region of the map's viewport.

    Returns undefined | LatLngBounds

  • getCenter(): undefined | LatLng
  • Returns the position displayed at the center of the map. Note that this google.maps.LatLng object is not wrapped. See LatLng for more information. If the center or bounds have not been set then the result is undefined.

    Returns undefined | LatLng

  • getClickableIcons(): undefined | boolean
  • Returns the clickability of the map icons. A map icon represents a point of interest, also known as a POI. If the returned value is true, then the icons are clickable on the map.

    Returns undefined | boolean

  • Available only in the v=beta channel: https://goo.gle/3oAthT3. Returns the FeatureLayer for the specified datasetId. Dataset IDs must be configured in the Google Cloud Console. If the dataset ID is not associated with the map's map style, or if Data-driven styling is not available (no map ID, no vector tiles, no Data-Driven Styling feature layers or Datasets configured in the Map Style), this logs an error, and the resulting FeatureLayer.isAvailable will be false.

    Parameters

    • datasetId: string

    Returns FeatureLayer

  • getDiv(): HTMLElement
  • Returns HTMLElement

  • Returns the FeatureLayer of the specific FeatureType. A FeatureLayer must be enabled in the Google Cloud Console. If a FeatureLayer of the specified FeatureType does not exist on this map, or if Data-driven styling is not available (no map ID, no vector tiles, and no FeatureLayer enabled in the map style), this logs an error, and the resulting FeatureLayer.isAvailable will be false.

    Parameters

    Returns FeatureLayer

  • getHeading(): undefined | number
  • Returns the compass heading of the map. The heading value is measured in degrees (clockwise) from cardinal direction North. If the map is not yet initialized then the result is undefined.

    Returns undefined | number

  • Informs the caller of the current capabilities available to the map based on the Map ID that was provided.

    Returns MapCapabilities

  • getMapTypeId(): undefined | string
  • Returns undefined | string

  • Returns the current Projection. If the map is not yet initialized then the result is undefined. Listen to the projection_changed event and check its value to ensure it is not undefined.

    Returns undefined | Projection

  • Returns the current RenderingType of the map.

    Returns RenderingType

  • Returns the default StreetViewPanorama bound to the map, which may be a default panorama embedded within the map, or the panorama set using setStreetView(). Changes to the map's streetViewControl will be reflected in the display of such a bound panorama.

    Returns StreetViewPanorama

  • getTilt(): undefined | number
  • Returns the current angle of incidence of the map, in degrees from the viewport plane to the map plane. For raster maps, the result will be 0 for imagery taken directly overhead or 45 for 45° imagery. This method does not return the value set by setTilt. See setTilt for details.

    Returns undefined | number

  • getZoom(): undefined | number
  • Returns the zoom of the map. If the zoom has not been set then the result is undefined.

    Returns undefined | number

  • Immediately sets the map's camera to the target camera options, without animation.

    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

  • panBy(x: number, y: number): void
  • Changes the center of the map by the given distance in pixels. If the distance is less than both the width and height of the map, the transition will be smoothly animated. Note that the map coordinate system increases from west to east (for x values) and north to south (for y values).

    Parameters

    • x: number

      Number of pixels to move the map in the x direction.

    • y: number

      Number of pixels to move the map in the y direction.

    Returns void

  • Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.

    Parameters

    Returns void

  • Pans the map by the minimum amount necessary to contain the given LatLngBounds. It makes no guarantee where on the map the bounds will be, except that the map will be panned to show as much of the bounds as possible inside {currentMapSizeInPx} - {padding}. For both raster and vector maps, the map's zoom, tilt, and heading will not be changed.

    Parameters

    • latLngBounds: LatLngBounds | LatLngBoundsLiteral

      The bounds to pan the map to.

    • Optional padding: number | Padding

      Padding in pixels. A number value will yield the same padding on all 4 sides. The default value is 0.

    Returns void

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

    Parameters

    • key: string
    • value: unknown

    Returns void

  • setClickableIcons(value: boolean): void
  • Controls whether the map icons are clickable or not. A map icon represents a point of interest, also known as a POI. To disable the clickability of map icons, pass a value of false to this method.

    Parameters

    • value: boolean

    Returns void

  • setHeading(heading: number): void
  • Sets the compass heading for map measured in degrees from cardinal direction North. For raster maps, this method only applies to aerial imagery.

    Parameters

    • heading: number

    Returns void

  • setMapTypeId(mapTypeId: string): void
  • Parameters

    • mapTypeId: string

    Returns void

  • Binds a StreetViewPanorama to the map. This panorama overrides the default StreetViewPanorama, allowing the map to bind to an external panorama outside of the map. Setting the panorama to null binds the default embedded panorama back to the map.

    Parameters

    Returns void

  • setTilt(tilt: number): void
  • For vector maps, sets the angle of incidence of the map. The allowed values are restricted depending on the zoom level of the map. For raster maps, controls the automatic switching behavior for the angle of incidence of the map. The only allowed values are 0 and 45. setTilt(0) causes the map to always use a 0° overhead view regardless of the zoom level and viewport. setTilt(45) causes the tilt angle to automatically switch to 45 whenever 45° imagery is available for the current zoom level and viewport, and switch back to 0 whenever 45° imagery is not available (this is the default behavior). 45° imagery is only available for satellite and hybrid map types, within some locations, and at some zoom levels. Note: getTilt returns the current tilt angle, not the value set by setTilt. Because getTilt and setTilt refer to different things, do not bind() the tilt property; doing so may yield unpredictable effects.

    Parameters

    • tilt: number

    Returns void

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

    Parameters

    • Optional values: null | object

    Returns void

  • setZoom(zoom: number): void
  • Sets the zoom of the map.

    Parameters

    • zoom: number

      Larger zoom values correspond to a higher resolution.

    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