# OpenLayers.Layer.Google

Provides a wrapper for Google’s Maps API Normally the Terms of Use for this API do not allow wrapping, but Google have provided written consent to OpenLayers for this - see email in http://osgeo-org.1560.n6.nabble.com/Google-Maps-API-Terms-of-Use-changes-tp4910013p4911981.html

#### Inherits from

- OpenLayers.Layer.SphericalMercator
- OpenLayers.Layer.EventPane
- OpenLayers.Layer.FixedZoomLevels

Summary

OpenLayers.Layer.Google | Provides a wrapper for Google’s Maps API Normally the Terms of Use for this API do not allow wrapping, but Google have provided written consent to OpenLayers for this - see email in http://osgeo-org.1560.n6.nabble.com/Google-Maps-API-Terms-of-Use-changes-tp4910013p4911981.html
Constants |
MIN_ZOOM_LEVEL | {Integer} 0
MAX_ZOOM_LEVEL | {Integer} 21
RESOLUTIONS | {Array(Float)} Hardcode these resolutions so that they are more closely tied with the standard wms projection
Properties |
type | {GMapType}
wrapDateLine | {Boolean} Allow user to pan forever east/west.
sphericalMercator | {Boolean} Should the map act as a mercator-projected map?
version | {Number} The version of the Google Maps API
Constructor |
OpenLayers.Layer.Google |
Functions |
clone | Create a clone of this layer
setVisibility | Set the visibility flag for the layer and hide/show & redraw accordingly.
display | Hide or show the Layer
moveTo |
setOpacity | Sets the opacity for the entire layer (all images)
destroy | Clean up this layer.
removeGMapElements | Remove all elements added to the dom.
removeMap | On being removed from the map, also remove termsOfUse and poweredBy divs
getOLBoundsFromMapObjectBounds |
getWarningHTML | {String} String with information on why layer is broken, how to get it working.
getMapObjectCenter | {Object} The mapObject’s current center in Map Object format
getMapObjectZoom | {Integer} The mapObject’s current zoom, in Map Object format
getLongitudeFromMapObjectLonLat |
getLatitudeFromMapObjectLonLat |
getXFromMapObjectPixel |
getYFromMapObjectPixel |
Properties |
OpenLayers.Layer.Google.cache | {Object} Cache for elements that should only be created once per map.
Constants |
OpenLayers.Layer.Google.v2 | Mixin providing functionality specific to the Google Maps API v2.
Properties |
termsOfUse | {DOMElement} Div for Google’s copyright and terms of use link
poweredBy | {DOMElement} Div for Google’s powered by logo and link
dragObject | {GDraggableObject} Since 2.93, Google has exposed the ability to get the maps GDraggableObject.
Functions |
loadMapObject | Load the GMap and register appropriate event listeners.
onMapResize |
setGMapVisibility | Display the GMap container and associated elements.
getMapContainer | {DOMElement} the GMap container’s div
getMapObjectBoundsFromOLBounds |
setMapObjectCenter | Set the mapObject to the specified center and zoom
dragPanMapObject |
getMapObjectLonLatFromMapObjectPixel |
getMapObjectPixelFromMapObjectLonLat |
getMapObjectZoomFromMapObjectBounds |
getMapObjectLonLatFromLonLat |
getMapObjectPixelFromXY |

### Constants

### MIN_ZOOM_LEVEL

{Integer} 0

### MAX_ZOOM_LEVEL

{Integer} 21

### RESOLUTIONS

{Array(Float)} Hardcode these resolutions so that they are more closely tied with the standard wms projection

### Properties

### type

{GMapType}

### wrapDateLine

{Boolean} Allow user to pan forever east/west. Default is true. Setting this to false only restricts panning if sphericalMercator is true.

### sphericalMercator

{Boolean} Should the map act as a mercator-projected map? This will cause all interactions with the map to be in the actual map projection, which allows support for vector drawing, overlaying other maps, etc.

### version

{Number} The version of the Google Maps API

### Constructor

### OpenLayers.Layer.Google

#### Parameters

name | {String} A name for the layer.
options | {Object} An optional object whose properties will be set on the layer.

### Functions

### clone

> clone: function()

Create a clone of this layer

#### Returns

{OpenLayers.Layer.Google} An exact clone of this layer

### setVisibility

> setVisibility: function( | visible | )

Set the visibility flag for the layer and hide/show & redraw accordingly. Fire event unless otherwise specified

Note that visibility is no longer simply whether or not the layer’s style.display is set to “block”. Now we store a ‘visibility’ state property on the layer class, this allows us to remember whether or not we desire for a layer to be visible. In the case where the map’s resolution is out of the layer’s range, this desire may be subverted.

#### Parameters

visible | {Boolean} Display the layer (if in range)

### display

> display: function( | visible | )

Hide or show the Layer

#### Parameters

visible | {Boolean}

### moveTo

> moveTo: function( | bounds,
> | zoomChanged,
> | dragging | )

#### Parameters

bounds | {OpenLayers.Bounds}
zoomChanged | {Boolean} Tells when zoom has changed, as layers have to do some init work in that case.
dragging | {Boolean}

### setOpacity

> setOpacity: function( | opacity | )

Sets the opacity for the entire layer (all images)

#### Parameters

opacity | {Float}

### destroy

> destroy: function()

Clean up this layer.

### removeGMapElements

> removeGMapElements: function()

Remove all elements added to the dom. This should only be called if this is the last of the Google layers for the given map.

### removeMap

> removeMap: function( | map | )

On being removed from the map, also remove termsOfUse and poweredBy divs

#### Parameters

map | {OpenLayers.Map}

### getOLBoundsFromMapObjectBounds

> getOLBoundsFromMapObjectBounds: function( | moBounds | )

#### Parameters

moBounds | {Object}

#### Returns

{OpenLayers.Bounds} An OpenLayers.Bounds, translated from the passed-in MapObject Bounds. Returns null if null value is passed in.

### getWarningHTML

> getWarningHTML:function()

#### Returns

{String} String with information on why layer is broken, how to get it working.

### getMapObjectCenter

> getMapObjectCenter: function()

#### Returns

{Object} The mapObject’s current center in Map Object format

### getMapObjectZoom

> getMapObjectZoom: function()

#### Returns

{Integer} The mapObject’s current zoom, in Map Object format

### getLongitudeFromMapObjectLonLat

> getLongitudeFromMapObjectLonLat: function( | moLonLat | )

#### Parameters

moLonLat | {Object} MapObject LonLat format

#### Returns

{Float} Longitude of the given MapObject LonLat

### getLatitudeFromMapObjectLonLat

> getLatitudeFromMapObjectLonLat: function( | moLonLat | )

#### Parameters

moLonLat | {Object} MapObject LonLat format

#### Returns

{Float} Latitude of the given MapObject LonLat

### getXFromMapObjectPixel

> getXFromMapObjectPixel: function( | moPixel | )

#### Parameters

moPixel | {Object} MapObject Pixel format

#### Returns

{Integer} X value of the MapObject Pixel

### getYFromMapObjectPixel

> getYFromMapObjectPixel: function( | moPixel | )

#### Parameters

moPixel | {Object} MapObject Pixel format

#### Returns

{Integer} Y value of the MapObject Pixel

### Properties

### OpenLayers.Layer.Google.cache

{Object} Cache for elements that should only be created once per map.

### Constants

### OpenLayers.Layer.Google.v2

Mixin providing functionality specific to the Google Maps API v2.

This API has been deprecated by Google. Developers are encouraged to migrate to v3 of the API; support for this is provided by OpenLayers.Layer.Google.v3

### Properties

### termsOfUse

{DOMElement} Div for Google’s copyright and terms of use link

### poweredBy

{DOMElement} Div for Google’s powered by logo and link

### dragObject

{GDraggableObject} Since 2.93, Google has exposed the ability to get the maps GDraggableObject. We can now use this for smooth panning

### Functions

### loadMapObject

> loadMapObject:function()

Load the GMap and register appropriate event listeners. If we can’t load GMap2, then display a warning message.

### onMapResize

> onMapResize: function()

### setGMapVisibility

> setGMapVisibility: function( | visible | )

Display the GMap container and associated elements.

#### Parameters

visible | {Boolean} Display the GMap elements.

### getMapContainer

> getMapContainer: function()

#### Returns

{DOMElement} the GMap container’s div

### getMapObjectBoundsFromOLBounds

> getMapObjectBoundsFromOLBounds: function( | olBounds | )

#### Parameters

olBounds | {OpenLayers.Bounds}

#### Returns

{Object} A MapObject Bounds, translated from olBounds Returns null if null value is passed in

### setMapObjectCenter

> setMapObjectCenter: function( | center,
> | zoom | )

Set the mapObject to the specified center and zoom

#### Parameters

center | {Object} MapObject LonLat format
zoom | {int} MapObject zoom format

### dragPanMapObject

> dragPanMapObject: function( | dX,
> | dY | )

#### Parameters

dX | {Integer}
dY | {Integer}

### getMapObjectLonLatFromMapObjectPixel

> getMapObjectLonLatFromMapObjectPixel: function( | moPixel | )

#### Parameters

moPixel | {Object} MapObject Pixel format

#### Returns

{Object} MapObject LonLat translated from MapObject Pixel

### getMapObjectPixelFromMapObjectLonLat

> getMapObjectPixelFromMapObjectLonLat: function( | moLonLat | )

#### Parameters

moLonLat | {Object} MapObject LonLat format

#### Returns

{Object} MapObject Pixel transtlated from MapObject LonLat

### getMapObjectZoomFromMapObjectBounds

> getMapObjectZoomFromMapObjectBounds: function( | moBounds | )

#### Parameters

moBounds | {Object} MapObject Bounds format

#### Returns

{Object} MapObject Zoom for specified MapObject Bounds

### getMapObjectLonLatFromLonLat

> getMapObjectLonLatFromLonLat: function( | lon,
> | lat | )

#### Parameters

lon | {Float}
lat | {Float}

#### Returns

{Object} MapObject LonLat built from lon and lat params

### getMapObjectPixelFromXY

> getMapObjectPixelFromXY: function( | x,
> | y | )

#### Parameters

x | {Integer}
y | {Integer}

#### Returns

{Object} MapObject Pixel from x and y parameters

> clone: function()

Create a clone of this layer

> setVisibility: function( | visible | )

Set the visibility flag for the layer and hide/show & redraw accordingly.

> display: function( | visible | )

Hide or show the Layer

> moveTo: function( | bounds,
> | zoomChanged,
> | dragging | )

> setOpacity: function( | opacity | )

Sets the opacity for the entire layer (all images)

> destroy: function()

Clean up this layer.

> removeGMapElements: function()

Remove all elements added to the dom.

> removeMap: function( | map | )

On being removed from the map, also remove termsOfUse and poweredBy divs

> getOLBoundsFromMapObjectBounds: function( | moBounds | )

> getWarningHTML:function()

{String} String with information on why layer is broken, how to get it working.

> getMapObjectCenter: function()

{Object} The mapObject’s current center in Map Object format

> getMapObjectZoom: function()

{Integer} The mapObject’s current zoom, in Map Object format

> getLongitudeFromMapObjectLonLat: function( | moLonLat | )

> getLatitudeFromMapObjectLonLat: function( | moLonLat | )

> getXFromMapObjectPixel: function( | moPixel | )

> getYFromMapObjectPixel: function( | moPixel | )

> loadMapObject:function()

Load the GMap and register appropriate event listeners.

> onMapResize: function()

> setGMapVisibility: function( | visible | )

Display the GMap container and associated elements.

> getMapContainer: function()

{DOMElement} the GMap container’s div

> getMapObjectBoundsFromOLBounds: function( | olBounds | )

> setMapObjectCenter: function( | center,
> | zoom | )

Set the mapObject to the specified center and zoom

> dragPanMapObject: function( | dX,
> | dY | )

> getMapObjectLonLatFromMapObjectPixel: function( | moPixel | )

> getMapObjectPixelFromMapObjectLonLat: function( | moLonLat | )

> getMapObjectZoomFromMapObjectBounds: function( | moBounds | )

> getMapObjectLonLatFromLonLat: function( | lon,
> | lat | )

> getMapObjectPixelFromXY: function( | x,
> | y | )

A mixin for layers that wraps up the pieces neccesary to have a coordinate conversion for working with commercial APIs which use a spherical mercator projection.
Base class for 3rd party layers, providing a DOM element which isolates the 3rd-party layer from mouse events.
Some Layers will already have established zoom levels (like google or ve).
{Boolean} Should the map act as a mercator-projected map?
Instances of this class represent bounding boxes.
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Mixin providing functionality specific to the Google Maps API v3.
Close