Google Maps API Tutorial

© 2006, 2007, 2008 Mike Williams

 

Unofficial Reference

This page is an unofficial reference to all the objects, classes, properties and methods that are accessible in the API

See also the Official Google Maps API Documentation

Business For Life Charity

This tutorial is provided by the Blackpool Community Church Javascript Team.

If you find this tutorial useful, you might consider making a donation to the Blackpool Community Church Business For Life Charity, which helps people in third world countries to help themselves by providing an individual with a grant to start up their own business.

Paypal and credit card donations accepted.

GAddCopyright
GAddMessages
GAdsManager
GBounds
GBrowserIsCompatible
GClientGeocoder
GControl
GControlPosition
GCopyright
GCopyrightCollection
GDirections
GDownloadUrl
GDraggableObject
GEvent
GFactualGeocodeCache
GGeoXml
GGeocodeCache
GGroundOverlay
GHierarchicalMapTypeControl
GIcon
GInfoWindow
GInfoWindowTab
GJsLoaderInit
GKeyboardHandler
GLargeMapControl
GLatLng
GLatLngBounds
GLoad
GLoadApi
GLoadMapsScript
GLog
GMap
GMap2
GMapType
GMapTypeControl
GMarker
GMarkerManager
GMenuMapTypeControl
GMercatorProjection
GOverlay
GOverviewMapControl
GPoint
GPolygon
GPolyline
GProjection
GRoute
GScaleControl
GScreenOverlay
GScreenPoint
GScreenSize
GScript
GSize
GSmallMapControl
GSmallZoomControl
GStep
GStreetviewClient
GStreetviewOverlay
GStreetviewPanorama
GTileLayer
GTileLayerOverlay
GTrafficOverlay
GUnload
GUnloadApi
GValidateKey
GVerify
GXml
GXmlHttp
GXslt
G_ANCHOR_BOTTOM_LEFT
G_ANCHOR_BOTTOM_RIGHT
G_ANCHOR_TOP_LEFT
G_ANCHOR_TOP_RIGHT
G_DEFAULT_ICON
G_DEFAULT_MAP_TYPES
G_GEO_BAD_KEY
G_GEO_MISSING_ADDRESS
G_GEO_SERVER_ERROR
G_GEO_SUCCESS
G_GEO_TOO_MANY_QUERIES
G_GEO_UNAVAILABLE_ADDRESS
G_GEO_UNKNOWN_ADDRESS
G_GOOGLEBAR_LINK_TARGET_BLANK
G_GOOGLEBAR_LINK_TARGET_PARENT
G_GOOGLEBAR_LINK_TARGET_SELF
G_GOOGLEBAR_LINK_TARGET_TOP
G_GOOGLEBAR_RESULT_LIST_INLINE
G_GOOGLEBAR_RESULT_LIST_SUPPRESS
G_HYBRID_MAP
G_HYBRID_TYPE
G_MAP_FLOAT_PANE
G_MAP_FLOAT_SHADOW_PANE
G_MAP_MAP_PANE
G_MAP_MARKER_MOUSE_TARGET_PANE
G_MAP_MARKER_PANE
G_MAP_MARKER_SHADOW_PANE
G_MAP_TYPE
G_MARS_ELEVATION_MAP
G_MARS_INFRARED_MAP
G_MARS_MAP_TYPES
G_MARS_VISIBLE_MAP
G_MOON_ELEVATION_MAP
G_MOON_MAP_TYPES
G_MOON_VISIBLE_MAP
G_NORMAL_MAP
G_PHYSICAL_MAP
G_SATELLITE_MAP
G_SATELLITE_TYPE
G_SKY_MAP_TYPES
G_SKY_VISIBLE_MAP

G_ANCHOR_BOTTOM_LEFT

Constant containing the number 2. Can be used for setting a GControlPosition() anchor.

G_ANCHOR_BOTTOM_RIGHT

Constant containing the number 3. Can be used for setting a GControlPosition() anchor.

G_ANCHOR_TOP_LEFT

Constant containing the number 0. Can be used for setting a GControlPosition() anchor.

G_ANCHOR_TOP_RIGHT

Constant containing the number 1. Can be used for setting a GControlPosition() anchor.

G_DEFAULT_ICON

A GIcon() object describing the default icon.
Has all the properties and methods of the GIcon() class.

G_DEFAULT_MAP_TYPES

An array of GMapType() objects identifying the map types which will be available by default.

G_GEO_BAD_KEY

A constant containing the code number that represents a GClientGeocoder failure due to an incorrect API key being used.

G_GEO_MISSING_ADDRESS

A constant containing the code number that represents a GClientGeocoder failure due to no address being submitted.

G_GEO_SERVER_ERROR

A constant containing the code number that represents a GClientGeocoder failure but the reason is not known.

G_GEO_SUCCESS

A constant containing the code number that represents a GClientGeocoder success.

G_GEO_TOO_MANY_QUERIES

A constant containing the code number that represents a GClientGeocoder failure due to your quota being exceeded..

G_GEO_UNAVAILABLE_ADDRESS

A constant containing the code number that represents a GClientGeocoder failure due to legal or contractual reasons.

G_GEO_UNKNOWN_ADDRESS

A constant containing the code number that represents a GClientGeocoder failure due to no known location matching the address.

G_GOOGLEBAR_LINK_TARGET_BLANK

A string constant that can be used in googleBarOptions.

G_GOOGLEBAR_LINK_TARGET_PARENT

A string constant that can be used in googleBarOptions.

G_GOOGLEBAR_LINK_TARGET_SELF

A string constant that can be used in googleBarOptions.

G_GOOGLEBAR_LINK_TARGET_TOP

A string constant that can be used in googleBarOptions.

G_GOOGLEBAR_RESULT_LIST_INLINE

A string constant that can be used in googleBarOptions.

G_GOOGLEBAR_RESULT_LIST_SUPPRESS

A string constant that can be used in googleBarOptions.

G_HYBRID_MAP

A GMapType() object describing the Hybrid Map Type
Has all the properties and methods of the GMapType() class.

G_HYBRID_TYPE

An alias for G_HYBRID_MAP for backwards compatibility with v1.

G_MAP_FLOAT_PANE

Constant containing the number 7. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_FLOAT_SHADOW_PANE

Constant containing the number 5. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_MAP_PANE

Constant containing the number 0. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_MARKER_MOUSE_TARGET_PANE

Constant containing the number 6. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_MARKER_PANE

Constant containing the number 4. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_MARKER_SHADOW_PANE

Constant containing the number 2. Can be used with the GMap2.getPane() method to get a reference to a pane.

G_MAP_TYPE

An alias for G_NORMAL_MAP for backwards compatibility with v1.

G_MARS_ELEVATION_MAP

A GMapType() object describing the Mars Elevation Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


G_MARS_INFRARED_MAP

A GMapType() object describing the Mars Infra Red Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


G_MARS_MAP_TYPES

An array of GMapType() objects identifying the map types associated with Mars. You can use it like {mapTypes:G_MARS_MAP_TYPES} when creating the GMap2.

Currently disabled by API loader parameters


G_MARS_VISIBLE_MAP

A GMapType() object describing the Mars Visible Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


G_MOON_ELEVATION_MAP

A GMapType() object describing the Lunar Elevation Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


G_MOON_MAP_TYPES

An array of GMapType() objects identifying the map types associated with the Moon. You can use it like {mapTypes:G_MOON_MAP_TYPES} when creating the GMap2.

Currently disabled by API loader parameters


G_MOON_VISIBLE_MAP

A GMapType() object describing the Lunar Visible Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


G_NORMAL_MAP

A GMapType() object describing the Normal Map Type
Has all the properties and methods of the GMapType() class.

G_PHYSICAL_MAP

A GMapType() object describing the Physical Map Type
Has all the properties and methods of the GMapType() class.


G_SATELLITE_MAP

A GMapType() object describing the Satellite Map Type
Has all the properties and methods of the GMapType() class.

G_SATELLITE_TYPE

An alias for G_SATELLITE_MAP for backwards compatibility with v1.

G_SKY_MAP_TYPES

An array of GMapType() objects identifying the map types associated with the sky view. You can use it like {mapTypes:G_SKY_MAP_TYPES} when creating the GMap2.

Currently disabled by API loader parameters


G_SKY_VISIBLE_MAP

A GMapType() object describing the Sky Map Type
Has all the properties and methods of the GMapType() class.

Currently disabled by API loader parameters


GAddCopyright()

This function can be used to add information about the copyright text for a region within a map type.

parameters
a string the getUrlArg() of the maptype to which the copyright applies.
b string id
c float min latitude
d float min longitude
e float max latitude
f float max longitude
g integer min zoom level
h string copyright text
i integer max zoom level
j booleanI'm not sure what this does


GAddMessages()

This undocumented function inserts text strings into the language specific message list.

parameters
a object An object specifying the list of messages.

For example:
GAddMessages({10093:'Conditions d\x27utilisation',10507:'Déplacer vers la gauche'});
replaces the texts "Terms of Use" and "Pan Left" with their French equivalents.


GAdsManager()

Controls the display of AdSense adverts on the map.

parameters
map the map on which the ads are to be displayed.
AdSense Id Publisher id of your AdSense account
opts options

options
maxAdsOnMap Maximum number of ads to be displayed: default = 3.
channel AdSense channel, can be used to track ad revenue.
minZoomLevel Minimum zoom level for ad display: default = 6.

Methods
enable()Enables ad display.
disable()Disables ad display.
copy()undocumented ?? Creates a new GAdsManager just like this one ??


GBounds()

Identifies a rectangular geographical region using APIv1 syntax, or a rectangular region specified in pixels

Constructor Can take two forms: undocumented new GBounds(minX, minY, maxX, maxY) or documented new GBounds(array)
If four parameters are passed, they are considered to be the long and lat values of the corner points.
If an array of GPoint()s or GLatLng()s is passed, then the a GBounds object that just includes those points is created.
properties
minXCoordinate of the West edge
maxXCoordinate of the East edge
minYCoordinate of the South edge
maxYCoordinate of the North edge
Methods
containsBounds(bounds)Returns true if it fully contains the other bounds
containsPoint(gpoint) Returns true if it contains the GPoint
copy()undocumented Returns a new GBounds that is a copy of this one.
equals(bounds)returns true if the two GBounds are equal
extend(point)Enlarges the bounds to be the smallest rectangle containing the previous area plus the specified location
toString()Returns a string in the format ((33.123, -120.123), (45.123, -100.234)).
max()Returns a GPoint() representing the Northeast corner.
min()Returns a GPoint() representing the SouthWest corner.
mid()Returns a GPoint() representing the centre.
Static Methods
GBounds().intersection(bounds,bounds)undocumented Returns a new GBounds representing the intersection of the two supplied GBounds
GBounds().intersects(bounds,bounds)undocumented Returns true if the two GBounds intersect.


GBrowserIsCompatible()

This function returns true if the current browser supports the Google Maps API.
 
parameters
a bool If true, the agent name is used as the class attribute of the <body> element. What it means in practice is that your page behaves as if you had written <body class="firefox"> or <body class="msie">, etc.

So by calling GBrowserIsCompatible(true) you can have different CSS behaviour depending on the browser, simply by writing different CSS styles for .opera, .netscape etc. The known compatible agent names are "opera", "msie", "safari", "firefox", "netscape" and "mozilla". If another browser happens to pass the compatibility tests (by supporting regExp and DOM, and not being a known incompatible browser) then you get whatever it uses as its agent name.


GClientGeocoder

Implements calls to the Google Geocoder.

Constructor new GClientGeocoder(gcache, key, client, channel). The parameters are optional.

If the first parameter is present it specifies the GGeocodeCache or GFactualGeocodeCache to be used. If omitted, a new GFactualGeocodeCache is created.

If the second parameter is present it specifies a key to be used for geocoding. This key is only used if the API code itself was loaded without a key.

Methods
getAddress(glatlng,callback)undocumetned Sends a reverse geocode request to the server.
I guess that it would return an address string if the reverse geocoding service were switched on. If the request fails, it returns null.
getAddresses(glatlng,callback)undocumetned Sends a reverse geocode request to the server.
I guess that it would return a structure similar to that returned by .getLocations() if the reverse geocoding service were switched on. If the request fails, it returns a structure containing an error code.
getCache()Returns a reference to the cache being used.
getLatLng(address,function)Passes a GLatLng to the function that identifies the location that most closely matches the address. If no address is found, "null" is passed to the function.
getLocations(address,function)Attempts to geocode the address and passes an anonymous structure containing reply details to the function.
reset()Resets the geocoder and clears its cache entries.
setCache(gcache)Changes the cache being used by the geocoder. If the parameter is omitted, caching is switched off.


GControl()

Creates a "control" structure, such as GMapTypeControl() or GLargeMapControl().
It is possible to create your own "control" structures with it, by applying your own methods.

Constructor new GControl(a,b);
a bool Set this true if the control structure is to be included when the map is printed.
If false or omitted, the structure is given the attribute class="gmnoprint".
b bool Set this true if the control structure is "selectable" (?).
Methods
clear()undocumented ?????
copy()undocumented Returns a copy of this GControl
getDefaultPosition()Set this to a function that returns the default position of your control structure as a GControlPosition() object.
initialize(a)Set this to a function that creates your control structure.
The optional parameter can be anything you want, just pass a suitable value when you use map.addControl() on it.
printable()Returns the first bool value you set in the constructor
selectable()Returns the second bool value you set in the constructor


GControlPosition()

Can be used to control the placement of GControl() objects.

Constructor new GControlPosition(anchor,offset);
anchor integer Specifies a corner of the map. Use one of the G_ANCHOR_BOTTOM_LEFT type variables.
offset GSize() Specifies the distance of the nearest point of the control div from the specified corner.
Methods
apply(element)Applies style attributes to an element that cause it to be positioned in the specified location. The element need not necessarily be the div of a GControl() object.
example
Suppose we have any HTML element with the attribute id="message". It can be positioned near the top left corner of the map by using

     var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(100,10));
     pos.apply(document.getElementById("control"));
     document.getElementById("map").appendChild(document.getElementById("control"));
This simply positions the element on top of the map. It doesn't turn it into a GControl(). Info windows will not attempt to avoid passing underneath it.

GCopyright

Stores the copyright texts for a region and range of zoom levels.

Constructor GCopyright(id, bounds, minZoom, text)
id integer Each GCopyright object must have a different id.
bounds GLatLngBounds Specifies the region of the map to which the copyright applies.
minZoom integer Specifies the lowest zoom level to which the copyright applies.
text string The copyright text to be displayed.
maxZoom integer Specifies the highest zoom level to which the copyright applies.
fbooleanI'm not sure what this does

properties and methods GCopyright has no accessible properties or methods.
 


GCopyrightCollection()

Holds all the GCopyright() objects that are related to a particular GTileLayer().
This initially starts off empty, but whenever the map changes to display a region where the information has not been collected, a new GAddCopyright() object will be fetches from the server and added to the collection.

Constructor new GCopyrightCollection(prefix)

parameters
prefix text Text to appear in the copyright string before the name of the copyright owner.
methods
addCopyright(gcopyright)Adds information from a GCopyright object to the collection.
getCopyrightNotice(latlngbounds,zoom) Returns a string containing the assembled copyright notice for the specified region and zoom level.
getCopyrights(latlngbounds, zoom)Returns an array of copyright strings that apply to the specified region and zoom level.


GDirections()

Constructor new GDirections(map, sidebar)

Both paramters are optional.

If the first parameter is present, then the route will be plotted on the map as a polyline with start and end markers, and the map will be centred and zoomed to fit the route. (You don't need to have previously performed map.setCenter().)

If the second parameter is present, then the route information will be appended to that HTMLElement, just like they are in the sidebar on maps.google.com.

If both parameters are used, then clicking on the entries in the sidebar will cause blowups to be shown on the map.

Methods
load(query,options) This is the Method that does all the hard work.
The first parameter is a string in the format "from: address to: address ...", e.g. "from: Chicago to: Pittsburgh to: New York"
The second parameter contains options
Note:GDirections.load() is asynchronous.
loadFromWaypoints(array,options)The same as .load() except that the first parameter is an array of locations, e.g. ["Chicago", "Pittsburgh"]
clear()Removes the direction information, removes the overlays, clears out the sidebar info.
getBounds()returns a GLatLngBounds that bounds the directions
getCopyrightsHtml()returns a HTML string containing the copyright associated with the directions.
getDistance()returns an Object that contains the distance information
.getDistance().html is a HTML string that describes the distance in suitable units
.getDistance().meters is a number indicating the distance in metres
getDuration()returns an Object that contains the duration information
.getDuration().html is a HTML string that describes the duration in suitable units
.getDuration().seconds is a number indicating the estimated duration in seconds
getGeocode(n)returns an Object that contains Geocode information about the start and end points.
.getGeocode(n).AddressDetails contains the address details returned from the geocoder
.getGeocode(n).Point contains the coordinates as three entries in an array: longitude, latitude and altitude
.getGeocode(n).address is a string containing the parsed address
.getGeocode(n).id - I don't know what this does.
getMarker(n)returns a reference to the start or end marker
getNumGeocodes()returns the number of geocodes
getNumRoutes()returns the number of routes (each waypoint adds an additional route)
getPolyline()returns a reference tot he polyline
getRoute(n)returns a GRoute Object
getStatus()returns an Object that contains the completion status
.getStatus().code returns the status code. 200=success. The error codes are the same as the error codes for geocoding.
.getStatus().request always seems to return "directions" even if the error obviously occurred in the geocoding.
getSummaryHtml()returns a HTML string containing something like "790 mi (about 12 hours 28 mins)"
Options
locale string Specifies the language to be used
getPolyline bool Instructs the system to return Polyline data. This defaults to true if the GDirections() Object was created with a map parameter.
getSteps bool Instructs the system to return text direstions. This defaults to true if the GDirections() Object was created with a sidebar parameter.
preserveViewport bool Suppresses the zoom that normally fits the view to the direction results.


GDownloadUrl()

This function will perform the GXmlHttp() processing required to fetch the contents of a text file. The specified file is read asynchronously, and when the read is complete, the data is passed as one long string to specified function.

You could use this to read a plain text data file, and use the String.split() method to split the result.

You could use this to read snippets of HTML code from a server, and drop the whole thing into a side panel

   loadPanel = function(a) {
     document.getElementById("sidePanel").innerHTML = a;
   }
   GDownloadUrl("server.php?query=getdetials&id=fred", loadPanel);
parameters
a string The URL of the file to be loaded.
b function The function to be called when the load has completed.
c string (Optional) Request to be POSTed to the server. If absent, the GET method will be used rather than POST.
d string (Optional) MIME type of the POST request. The default is "application/x-www-form-urlencoded".

With the GET method, any request data is limited to the 512 bytes that can be appended as parameters to the end of the URL.
With the POST method, large amounts of request data can be sent to the server, and the MIME type can be specified.


GDraggableObject

Constructor new GDraggableObject(HTMLElement, opts)

Options
container HTML Element An element that will act as a bounding box for the draggable object
draggableCursor string The cursor to show on mousover.
draggingCurosr string The cursor to show while dragging.
left Number The left starting position of the object.
top Number The top starting position of the object.
restrictX Boolean undocumented I have no idea what this does.
scroller object of unexposed class undocumented Object that performs the actual drag operation.

Properties
leftHorizontal starting position of object
topVertical starting position of object

Note Setting the .top and .left of a GDraggableObject() will not immediately move the html element. The element will jump to the specified position the next time it starts to be dragged.

Static Methods
getDraggableCursor()Returns a string containing the current draggable cursor setting.
getDraggingCursor()Returns a string containing the current dragging cursor setting.
setDraggableCursor(string) Sets the cursor to be used for subsequent draggable objects
setDraggingCursor(string) Sets the cursor to be used for subsequent draggable objects while they are being dragged

Standard cursors are "auto", "crosshair", "default", "help", "move", "pointer", "text", "wait", and in some browsers "hand".

See Custom Cursors for info about using your own custom cursors.

Instance Methods
disable() Disables dragging
dragging() Returns true if the object is currently being dragged
enable() Enables dragging
enabled() Returns true if dragging is currently enabled
moveTo(see below)Moves the object to the specified location
moveBy(see below)Moves the object by the specified pixel offset

The parameters for .moveTo() in v2.84 to v2.88 were two integers: left, top.
From v2.89 there's a single GPoint() parameter.

The parameters for .moveBy() in v2.86 to v2.88 were two integers: left, top.
From v2.89 there's a single GSize() parameter.


GEvent

Handles event registration and triggering.

Here's a list of the event types that can occur on directly accessible objects.
GCopyrightCollectionnewcopyright
GMap2addmaptype, addoverlay, clearoverlays, click, dblclick, drag, dragend, dragstart, infowindowbeforeclose, infowindowclose, infowindowopen, infowindowprepareopen, infowindowupdate, load, maptypechanged, markerload, markerunload, move, moveend, movestart, mousemove, mouseout, mouseover, mousewheel, removemaptype, removeoverlay, resize, singlerightclick, tilesloaded, zoomend, zooming, zoomstart, DOMMouseScroll
GMap[all the GMap2 events], zoom
GMapTypenewcopyright
GMarkerclick, changed, dblclick, infowindowbeforeclose, infowindowclose, infowindowopen, infowindowprepareopen, mousedown, mouseout, mouseover, mouseup, remove, updatejson, visibilitychanged
GMarkerManager changed
GPolygonclick, remove, visibilitychanged
GPolylineclick, remove, visibilitychanged
GTileLayernewcopyright
GKeyboardHandlermoveend, movestart
GInfoWindowanimate, closeclick, maximizeclick, maximizeend, restoreclick, restoreend
anythingclearlisteners
documentlogclick
GDraggableObjectclick, dblclick, drag, dragend, dragstart, mousedown, mouseup, move

GEvent.addDomListener() Adds an event listener to a HTML element.
parameters
a object The html element on which the events may occur, e.g. document.getElementById("button")
b string The name of the event, e.g. "click" or "moveend"
c function A function to handle the event. Can be an anonymous function or a function name.

GEvent.addListener() Adds an event listener.
parameters
a object The object on which the events may occur, e.g. a marker or the map
b string The name of the event, e.g. "click" or "moveend"
c function A function to handle the event. Can be an anonymous function or a function name.

GEvent.bind() Binds the given method of the given object to the given source event
parameters
a object The object on which the events may occur, e.g. a marker or the map
b string The name of the event, e.g. "click" or "moveend"
c object The object which will be the "this" when the method is called
d method A method to handle the event

GEvent.bindDom() Binds the given method of the given HTML Element to the given source event
parameters
a object The HTML Element on which the events may occur, e.g. document.getElementById("button")
b string The name of the event, e.g. "click" or "moveend"
c object The object which will be the "this" when the method is called
d method A method to handle the event

GEvent.callback() Returns a function that calls the second parameter as a method of the first parameter.
parameters
a object the object to which the method is to be applied
b function the function to be used as a method of the object

GEvent.callbackArgs() Returns a function that calls the second parameter as a method of the first parameter.
parameters
a object the object to which the method is to be applied
b function the function to be used as a method of the object
Any additional parameters are passed to the method

GEvent.clearInstanceListeners() Removes all listeners on a specified object.
parameters
a object The object on which the events may occur, e.g. a marker or the map

GEvent.clearListeners() Removes all listeners of a specified type on a specified object.
parameters
a object The object on which the events may occur, e.g. a marker or the map
b string The name of the event, e.g. "click" or "moveend"

GEvent.clearNode() Removes all listeners on a specified object and those on its child nodes.
parameters
a object The object on which the events may occur, e.g. a marker or the map

GEvent.removeListener() Removes a named listener.
parameters
a listener The listener to be removed. Use the token that was returned from the GEvent.addListener() call

GEvent.trigger() Triggers an event.
parameters
a object The object on which the events is to be triggered, e.g. a marker or the map
b string The name of the event, e.g. "click" or "moveend"
Any additional parameters are passed tot he event handler function.


GFactualGeocodeCache

Stores Geocode information.

Constructor new GFactualGeocodeCache()

It is the same as the GGeocodeCache class, except that its .isCacheable() method performs stricter tests.


GGeocodeCache

Stores Geocode information.

Constructor new GGeocodeCache()

Methods
get(address)Returns the reply that was stored for this address.
isCacheable(reply)Returns true if the GClientGeocoder.getLocations() reply should be cached.
put(address,reply)Stores the address and its reply in the cache, if the reply is cacheable.
reset()Erases the contents of the cache.
toCanonical(address)Returns the address in "canonical" form, using standardized punctuation and lower case.


GGeoXml

Renders a KML or GeoRSS file as a map overlay.

Constructor
GGeoXml accepts an indefinite number of parameters, which include:

parameters
url string URL of KML or GeoRSS file
The file must be placed on a webhost where the Google server can read it
callback function Function to be called when processing is complete
sideBarHandler function undocumented Function to be notified of the structure and contents of the items added
opts options object undocumented I don't know what options are available.

Use map.addOverlay() to add the overlay to the map.

methods
copy()Returns a new GOverlay that is a copy of this one.
initialize()Used by map.addOverlay() to set up the overlay.
redraw()The overlay is redrawn.
remove()Used by map.removeOverlay() to recover memory.
supportsHide()Returns false, thus indicating that the overlay does not support .hide(), .show() and .isHidden()
getDefaultBounds() Returns a GLatLngBounds that contains all the objects added.
getDefaultCenter() Returns a GLatLng at the centre of those bounds.
getDefaultSpan() Returns a GLatLng. The coordinates of the GLatLng represent the width abd height of those bounds.
getTileLayerOverlay() Returns the tile layer overay that GGoeXml has used, if there is one. Otherwise returns null.
gotoDefaultViewport() Sets the viewport to fit the objects added
hasLoaded() Returns true if the loading is complete
loadedCorrectly() Returns true if the XML file loaded correctly (only meaningful if .hasLoaded() is true)

The .hide() and .show() methods also exist, but they simply throw a "Interface not implemented" error.

Extra overlay properties

GGeoXml can add extra properties to the overlays that it creates. They are all undocumented. Note that not all overlays have all these properties. They always seem to have description, snippet and name but the presence of other properties varies. It's possible that you either get hiddenInStream or (parentGeoXml and parentFolderForCallbackOverlayAddTimeout) I'm not sure about that.
description text from the <description> field in the KML
name text from the <name> field in the KML
snippet text from the <snippet> field in the KML
hiddenInStream boolean: I don't know what this does
parentFolderForCallbackOverlayAddTimeout Integer: I don't know what this does
parentGeoXml pointer to the parent GEoXml object


GGroundOverlay

Renders an image file as a map overlay.

Constructor new GGroundOverlay(url, latlngbounds, opts)

Use map.addOverlay() to add the overlay to the map.

methods
copy()Returns a new GOverlay that is a copy of this one.
hide() Hides the overlay
initialize(map)Used by map.addOverlay() to set up the overlay.
isHidden() returns true if the overlay is hidden
redraw()Redraws the overlay.
remove()Used by map.removeOverlay() to recover memory.
show() Shows the overlay
supportsHide()Returns true, thus indicating that the overlay supports .hide(), .show() and .isHidden()

The .hide() and .show() methods also exist, but they simply throw a "Interface not implemented" error.

I don't know what options exist or what they do. The code that handles the opts is particularly obscure.


GHierarchicalMapTypeControl()

A GControl() structure that manages map type switching, typically in the top right corner of the map. Has all the properties and methods of the GControl() class.

Similar to GMapTypeControl() except that it uses a parent/child layout instead of a row of separate buttons.

It additionally accepts an optional parameters.

parameters
tiny bool If present and true, the control will use short names in the map type buttons.

methods
addRelationship(parent, child, name, isDefault)Makes one map type a child of another.
The first two parameters are required references to the parent and child GMapType instances.
The third optional parameter allows you to specify a different name for the child box in the layout.
The fourth optional parameter can be set true to cause the child maptype to be activated when the parent maptype is selected.
removeRealationship(child) Removes the relationship from a child GMapType.
clearRelationships() Clears all the relationships. All GMapTypes become parents.


GIcon()

Constructor new GIcon(gicon, image, label, shadow)
All parameters are optional.

If the first parameter is present, then all properties of that GIcon() object are copied to the new GIcon().

If the second parameter is present, then it is used for the GIcon().image property.
If the fourth undocumented parameter is present, then it is used for the GIcon().shadow property.
E.g. var myIcon = new GIcon(G_DEFAULT_ICON, "mymarker.png")creates a GIcon() that has the same shape and size as the default icon, but has a different image.

If the third undocumented parameter is present it is used as a "label"
A "label" is an extra image component that lies on top of the main icon image. This feature allows you to build your icon from a background image plus a foreground label. Prior to the introduction of this feature, if you wanted to have markers with different letters and different background colours, you had to create a separate icon image for each combination.
The label is an object of unnamed class that has the following properties:
label undocumented
urlThis string identifies the URL of the label image file.
sizeA GSize() object that identifies the pixel size of the label image.
anchorA GPoint() object that identifies the position offset of the label image relative to the main image.
properties
imageThis string identifies the main image of the marker.
iconSizeA GSize() object that identifies the pixel size of the main image.
shadowOptional string that identifies the image to be used for the shadow.
shadowSizeA GSize() object that identifies the pixel size of the shadow image.
iconAnchorA GPoint() object which identifies the pixel which will be placed on the specified geographical location. You can think of it as the point that the image points at.
infoWindowAnchorA GPoint() object which identifies the pixel that the tip of the info window stem will touch.
labelundocumented (Optional) see above
transparent(Optional) is the name of a transparent image used for capturing clicks and mouseovers in IE.
printImage(Optional) identifies a GIF file to be used for printing.
mozPrintImage(Optional) identifies a GIF file to be used for printing from the Mozilla or Firefox browser.
printShadow(Optional) identifies a GIF file to be used for printing the shadow.
imageMap(Optional) an array of integers representing the "shape" parameters of a HTML ImageMap. Used for capturing marker clicks in non-IE browsers.
imageMapType(Optional) Undocumented specifies the shape type of the ImageMap. Can be "poly", "circle" or "rect".
dragCrossAnchorGPoint(): indicates the hot spot of the drag cross image, but with the x coordinate negated. E.g. if you want the anchor point of your image to be the pixel (4,9) then you need to specify "new GPoint(-4,9)"
dragCrossImageString: indicates an image to be used as the drag cross. If you set it to the null string, you get the default drag_cross_67_16.png image.
dragCrossSizeGSize(): indicates the size of the drag cross.
maxHeightinteger: The maximum difference in height between the marker anchor and the drag cross anchor during dragging. Setting the maxHeight to zero causes it to use the default 13.


GInfoWindow()

There is only one object in the GInfoWindow class. You can obtain a reference to it via map.getInfoWindow() and then use its methods.

The class itself in no longer exposed, so you can't create new GInfoWindow() objects.

Properties GInfoWindow has no accessible properties

methods
create(pane1,pane2)undocumented Used by .initialize() to create the divs.
The parameters are references to the panes in which the info window and the shadow are to be placed.
getContentContainers()Returns the array of HTML Elements reprenting the contents of each tab.
getTabs()Returns the array of GInfoWindowTab() objects in this info window
maximize(instant)Expands the infowindow. Only works if the infowindow has a maxUrl or maxContent.
If the undocumented parameter is true, then the large infowindow opens instantly, otherwise an animation is performed.
restore(instant) Contracts an expanded infowindow. Only works if the infowindow has a maxUrl or maxContent.
If the undocumented parameter is true, then the small infowindow opens instantly, otherwise an animation is performed.
reposition(latlng,pixeloffset) undocumented Moves an info window. Parameters are the new geographical location and a GSize() pixel offset from that location.
getPixelOffset()Returns the pixel offset of the info window
getPoint()Returns a GLatLng indicating the location of the info window
getSelectedTab()Returns a number indicating which tab is selected, counting from zero.
hide()Makes the info window invisible
initialize(map)undocumented Used by the openInfoWIndow methods to create the info window if it does not exist
isHidden()Returns true if the info window is hidden or closed
redraw(force)undocumented Redaws the info window if the parameter is true.
remove()undocumented destroys the info window divs
reset(point, tabs, size, offset, selectedTab)Changes some or all of the info window properties.
The fourth and fifth arguments are optional.
  • point: a GLatLng() indicating the geographical location.
  • tabs: array of GInfoWindowTab()s with HTML DOM elements (not HTML text strings) in the contentElem.
  • size: a GSize() indicating the size of the info window display area. When using .reset(), the API will not automatically calculate the size for you, but will enforce the minimum size if you try to set it smaller.
  • offset: (optional) a GSize() indicating the pixel offset.
  • selectedTab: (optional) an integer indicating which tab is selected.
selectTab(i)Activates the specified tab
show()Makes the info window visible
supportsHide()Returns true, thus indicating that the overlay supports .hide(), .show() and .isHidden()
disableMaximize()If the info window is open, removes the "maximize" icon from the info window and disables maximization.
enableMaximize()If the info window is open, displays the "maximize" icon in the info window and enables maximization if the corresponding options are set.

GInfoWindowTab()

These are used to hold information about the tabs of tabbed info windows.

Constructor
new GInfoWindowTab(label,contents)

properties
contentElemundocumented HTML elements representing the contents of the info window corresponding to this tab
It must be a HTML DOM element if using .openInfoWindow(), and must be a HTML string if using .openInfoWindowHtml().
nameundocumented Text displayed in the tab to identify it
onclickundocumented Possibly an optional function to be called when the tab is clicked.


GJsLoaderInit()

This function us involved with loading and initialising an optional API Javascript module.

The API now has the ability to load optional code modules. This means that if you don't want to use the traffic overlay in your map, then you don't need to load the traffic module.

parameters
a string The full URL of the main API code


GKeyboardHandler()

Create one of these if you want your map to respond to keyboard input like Google Local does.

Constructor
new GKeyboardHandler(map,window)

(The second parameter is undocumented)

The GKeyboardHandler has no accessible properties or methods.

GLargeMapControl()

A GControl() object controlling zooming an panning
Has all the properties and methods of the GControl() class.

GLatLng()

Identifies a geographical location.

Constructor new GLatLng(latitude,longitude, nofix)
(Note that the latitude and longitude are in the opposite order from GPoint)
If the optional nofix parameter is absent or false, the latitude is restricted to the range -90 to +90, and the longitude is wrapped round the globe to the value in the range -180 to +180. E.g. (-100,270) would become (-90,-90)

The constructor initially creates the x and y parameters as copies of the hidden parameters that control the location. Changing the values of the x and y parameters does not change the location of the GLatLng object.

Properties
yLatitude expressed in degrees (read only, deprecated)
xLongitude expressed in degrees (read only, deprecated)
Methods
lat()Returns the latitude
lng()Returns the longitude
latRadians()Returns the latitude expressed in radians
lngRadians()Returns the longitude expressed in radians
distanceFrom(latlng, radius of planet)Returns the distance expressed in metres from the specified location.
The second parameter is optional.
equals(latlng)Returns true if the two latlngs identify the same location
toString()undocumented Returns a string in the format "(1.123456789,-1.123456789)"
toUrlValue(n)Returns a string in the format "1.123457,-1.123457". The values are rounded to n decimal places (default 6).
copy()undocumented Returns a new GLatLng with the same value as this one.

Static Methods
GLatLng.fromRadians(lat,lng,nofix)undocumented Constructs a GLatLng from radian values instead of degrees
GLatLng.fromUrlValue(string)undocumented Constructs a GLatLng from a string in the format "1.123457,-1.123457".


GLatLngBounds()

Identifies a rectangular geographical region

Constructor new GLatLngBounds(latlng,latlng)
If two parameters are passed, they are taken to represent the SouthWest and NorthEast corners of the rectangle. The corners must be in the right order for it to work correctly.
If one parameter is passed, the region contains just that point.
If no parameters are passed, the regions is set to the empty region GLatLngBounds(new GLatLng(57.29577951308232, 180), GLatLng(-57.29577951308232, -180)). (The corners are in the wrong order).

All the coordinates are normalized into the range -90 to +90 for the latitudes and -180 to +180 for the longitudes.
properties: GLatLngBounds has no accessible properties

Methods
contains(latlng)Returns true if the bounds contain the location
containsBounds(latlngbounds)Returns true if it fully contains the other bounds
containsLatLng(glatlng)Returns true if it contains the GLatLng
equals(latlngbounds)Returns true if the bounds are equal
extend(latlng)Enlarges the bounds to be the smallest rectangle containing the previous area plus the specified location
getCenter()Returns a GLatLng representing the centre
getNorthEast()Returns a GLatLng representing the NorthEast corner
getSouthWest()Returns a GLatLng representing the SouthWest corner
intersects(latlngbounds)Returns true if the two bounds intersect
isEmpty()Returns true if the bounds specify a negative region (i.e. the corners are specified in the wrong order)
isFullLat()Returns true if the latitude range covers the whole Earth from -90 to +90
isFullLng()Returns true if the longitude range covers the whole Earth -180 to +180
toSpan()Returns a GLatLng object which represents the width and height of the region.
toString()undocumented Returns a string in the format ((33.123, -120.123), (45.123, -100.23399999999998)). The values may differ slightly from what you originally specified due to being converted to radians and back to degrees.


GLoad()

undocumented

This function is used during the API loading sequence, to load the API.
 


GLoadApi()

undocumented

This function is used during the API loading sequence, to pass information from the loader code to the API.

parameters
a array of strings List of server paths for MAP tiles
b array of strings List of server paths for SATELLITE tiles
c array of strings List of server paths for HYBRID overlay tiles
d string API key hash
e string geocoder "&client" parameter.
f string geocoder "&channel" parameter.
g boolean If true, the Google Logo is displayed.
h string Google prefix letter, default="G"
i object options
k array of strings List of server paths for PHYSICAL tiles

The possible options are:
public_api bool If false, G_PHYSICAL_MAP is added to the active map types.
async bool If true, <style> settings (such as .gmnoprint) are inserted using document.write()
If false, using document.getElementsByTagName("head").appendChild()


GLoadMapsScript()

undocumented

This function is used during the API loading sequence to load the selected API Javascript file.
 


GLog()

A system that allows debugging information to be displayed.
The GLog() methods are all static. You call them like 'GLog.write(text);' rather than using 'var log = new GLog(); log.write(text)'

methods
write(txt,colour)Writes the text to a log window that appears at the bottom of the screen.
The optional colour parameter can be a string containing a colour specification, like "blue" or "#FF8888".
writeHtml(txt)Writes the text to a log window that appears at the bottom of the screen, applying any HTML formatting.
writeUrl(txt)Writes the text to a log window that appears at the bottom of the screen, formatted as a clickable link.
getMessages()undocumented Returns an array of strings containing the text of all messages perviously written.


GMap()

A Gmap() object is a GMap2() object with a few extra methods layered on top, to provide backward compatibility.

Constructor new GMap(a,b,c,d)

parameters
a html element The map container, usually a <div>
b[ ] array of maptypes (optional) list of map types allowed on this map
c integer (optional) Width of map
d integer (optional) Height of map
properties GMap() has no accessible properties

additional methods
centerAndZoom(point,zoom)Centres and zooms the map
centerAtLatLng(point)Centres the map
getBoundsLatLng()Returns a GBounds() object identifying the map bounds.
getCenterLatLng()Returns a GPoint() identifying the centre
getSpanLatLng()Returns a GSize() identifying the width and height of the map in lng and lat degrees
getZoomLevel()Returns the APIv1 type zoom level.
Note that this can be a negative value when the new deep v2 zoom levels are active.
openInfoWindowXslt()Does nothing
recenterOrPanToLatLng(point)Centres the map, doing a fluid pan to the point if it is within the current viewport
zoomTo(zoom)
overwritten methods These methods overwrite the GMap2() methods of the same name
setMapType(a)Sets the map type. The parameter is a GMapType() object.
openInfoWindow(a,b,c,d,e)Opens the info window, see below for parameters
openInfoWindowHtml(a,b,c,d,e)Opens the info window, see below for parameters
Modified EventReturns
zoomendoldZoom, newZoom (using APIv1 zoom level syntax)


GMap2()

Constructor new GMap2(container,opts)

parameters
container html element The map container, usually a <div>
opts (optional)Anonymous object may contain more information

opts If you want to set up any of the other internal properties of your GMap2() you have to bundle them into an anonymous object. The constructor copies the named properties of this anonymous object into the hidden internal properties of the GMap2. E.g.

  var map = new GMap2(document.getElementById("map"),{mapTypes:[G_SATELLITE_TYPE]});
propertytypepurpose
mapTypesArray of GMapType()sList of map types allowed on this map
sizeGSize()Size of map
draggableCursorstringSpecifies a cursor to use when the map is draggable
draggingCursorstring Specifies a cursor to use when the map is being dragged
googleBarOptionsoptions objectSpecifies a set of options to be applied to the Google Bar, if present
noResizeboolundocumented Suppresses "resize" events
suppressCopyrightboolundocumented Set true to suppress the copyright message (e.g. for overview maps and blowup maps)
usageTypestringundocumented Possible values are "o" for overview maps and "p" for blowup maps.
logoPassivestringundocumented Set true to make the Google Logo unclickable.
mapOrderMarkersfunction(GMarker,GMarker) returning an integerundocumented The API will use this as an "order function" in an Array.sort() call, to sort its internal array of markers.
The function should return a negative or positive value depending on whether the first GMarker is to be sorted before or after the second GMarker.

I have no idea why you might want to do this.

Standard cursors are "auto", "crosshair", "default", "help", "move", "pointer", "text", "wait", and in some browsers "hand".

See Custom Cursors for info about using your own custom cursors.

googleBarOptions

The possible entries in the googleBarOptions are:
propertytypepurpose
showOnLoadboolIf true, the Google Bar will be expanded when the map has loaded.
linkTargetstringUse one of these string variables to control the link target pane G_GOOGLEBAR_LINK_TARGET_BLANK, G_GOOGLEBAR_LINK_TARGET_PARENT, G_GOOGLEBAR_LINK_TARGET_SELF, G_GOOGLEBAR_LINK_TARGET_TOP
resultListstringUse one of these string variables to control result list suppression G_GOOGLEBAR_RESULT_LIST_INLINE, G_GOOGLEBAR_RESULT_LIST_SUPPRESS
suppressInitialResultSelectionboolIf true, the info window is not opened on the firest result.
suppressZoomToBoundsboolIf true, the map does not zoom and pan to fit the results.
onIdleCallbackfunctionFunction be be called when the GoogleBar finishes searching
onSearchCompleteCallbackfunctionFunction to be called when the search is complete, before the reults are plotted
onGenerateMarkerHtmlCallbackfunctionFunction to be called when the info window is about to be opened on one of the results. Must return the (modified) html string to be used for the info window contents.
onMarkersSetCallbackfunctionFunction to be called after the markers have been placed on the map.

methods
addControl(control,controlposition)Causes the GControl() object to be added to the map If a GControlPosition() is not specified, the getDefaultPosition() is used.
addMapType(maptype) Adds a map type to the map
addOverlay(overlay)Causes the overlay to be added to the map.
checkResize()Checks to see if the map container has changed size, and if so resizes the map
clearOverlays()Removes all overlays except GTileLayerOverlay()s.
closeInfoWindow()Closes the info window
continuousZoomEnabled()Returns true if "continuous zoom" animations are enabled.
disableContinuousZoom()Disables the "continuous zoom" animations.
disableDoubleClickZoom()Causes double-click to just centre the map.
disableDragging()Disables map dragging
disableGoogleBar()Removes the Google Bar
disableInfoWindow()Disables the info window
disableScrollWheelZoom() Disables the scroll wheel zoom.
doubleClickZoomEnabled()Returns true if double click zoom is enabled.
draggingEnabled()Returns true if map dragging is enabled.
enableContinuousZoom()Enables the "continuous zoom" animations - zooming in or out by one level is then amimated.
enableDragging()Enables map dragging.
enableDoubleClickZoom()Causes double-click to zoom in by one level and centre the map.
enableInfoWindow()Enables the info window
enableGoogleBar()Activates a Google Bar on top of the Google Logo
enableScrollWheelZoom() Enables the scroll wheel zoom.
focus()Undocumented If the info window is open, returns its location as a GLatLng().
fromContainerPixelToLatLng(point)Converts a container pixel to a GLatLng()
fromDivPixelToLatLng(latlng,nofix)Converts a "dragObject" div pixel to a GLatLng()
If the optional second undocumented parameter is true, then the output is not normalized.

Note: The values for ContainerPixel and DivPixel are initially the same, but the div moves when the map pans and the container doesn't. Markers keep the same DivPixel position when the map moves, and only get a new value when it zooms.

fromLatLngToContainerPixel(latlng)Converts a GLatLng() to a pixel relative to the map container.
fromLatLngToDivPixel(latlng,point)Converts a GLatLng() to a "dragObject" div pixel
The optional second parameter is for resolving normalization ambiguities. When zoomed out, the same latlng position can be present on more than one tile. Without the second parameter, the copy nearest the centre is chosen. If the second parameter is present, its .x value controls which copy is chosen.
getBounds()Returns a GLatLngBounds which indicates the bounds of the region covered by the map.
getBoundsZoomLevel(latlngbounds)Returns the number of the deepest permitted zoom level of the current map type which is large enough to contain the specified region.
getCenter()Returns a GLatLng() indicating the centre point of the map.
getContainer()Returns a reference to the map <div>
getCurrentMapType()Returns a reference to the current GMapType()
.getDragObject() Returns a reference to the special GDraggableObject that contains all the parts of the map that move when the map pans: the map tiles and overlays, but not the map controls.
All the properties and instance methods of GDraggableObject are accessible.
getInfoWindow()Returns a reference to the info window object.
getMapTypes()Returns an array of GMapType()s that are allowed on this map.
getPane(i)Returns a reference to one of the map panes.

The draggable part of the map contains seven html <div> elements referred to as "panes". Different types of map elements are placed in different panes, e.g. the map tiles are placed in the lowest pane, markers are placed on a higher plane.
The values G_MAP_MARKER_SHADOW_PANE, G_MAP_MARKER_PANE, G_MAP_FLOAT_SHADOW_PANE, G_MAP_MARKER_MOUSE_TARGET_PANE, G_MAP_FLOAT_PANE can be used to specify a specific pane.

getSize()Returns a GSize() object indicating the size of the map in pixels.
getZoom()Returns the current zoom level number.
hideControls()undocumented Hides all hideable controls. The Logo, copyright and Terms are not hideable, all other controls are hideable.
infoWindowEnabled()Returns true if the info window is enabled
infoWindowSizeWatcher()undocumented This has something to do with GGeoXml.
isLoaded()Returns true if the map has a map type.
When initially created, a map has no map type. It will be given a map type the first time that setCenter() or setMapType() or setZoom() is used.
openInfoWindow(a,b,c)Opens the info window, see below for parameters
openInfoWindowHtml(a,b,c)Opens the info window, see below for parameters
openInfoWindowTabs(a,b,c)Opens the info window, see below for parameters
openInfoWindowTabsHtml(a,b,c)Opens the info window, see below for parameters
panBy(gsize)Pans the map by the specified number of pixels in the x and y directions.
panDirection(a,b)Pans in the direction specified by (a,b)
e.g. map.panDirection(2,-1) causes the screen to pan two units North and one unit West
Each pan unit is equal to half a screen.
panTo(a)Recentres or pans to the specified GLatLng() position
removeControl(a)Removes a GControl(). The parameter is the token returned from addControl()
removeMapType(maptype) Removes a map type
removeOverlay(a)Removes an overlay.
returnToSavedPosition()Resets the map to the values saved by map.savePosition()
savePosition()Saves the map centre and zoom level information which gets used when the user clicks on the "Return to last result" icon
scrollWheelZoomEnabled()Returns true if the scroll wheel zoom is enabled.
setCenter(a,b,c)If "a" is present, it is a GLatLng() specifying the new map centre.
If "b" is present, it is n integer specifying the new zoom level.
If "c" is present, it is a GMapType() specifying the new map type.
All three parameters are optional.
setFocus(latlng,force) undocumented Normally when you zoom in or out, the centre point stays in a fixed location on the screen. setFocus(latlng) changes this behaviour so that the specified point is the one that remains in a fixed location. If a zoom animation is in progress, then setFocus is ignored unless the second parameter is set true.
setFocus() with no parameters changes things back to the default behaviour.
setMapType(a)Sets the map type. The parameter is a GMapType() object.
setZoom(a)Sets the zoom level. The parameter is an integer.
showControls()undocumented Makes hidden controls visible.
showMapBlowup(a,b)Opens the info window with a blowup maplet, see below for parameters
zoomIn(latlng,bool,bool)Zooms in by one zoom level
If the first undocumented parameter is present and the second parameter is present and true, then the map is centred at the specified GLatLng
If the first undocumented parameter is present and the second parameter is absent or false, then the map centre is shifted in such a way that the specified GLatLng remains in the same position relative to the map container
If the third undocumented parameter is present and set to true, then an animated zoom is performed if continuous zoom is enabled.
zoomOut(latlng,bool)Zooms out by one zoom level
If the first undocumented parameter is present then the map centre is shifted in such a way that the specified GLatLng remains in the same position relative to the map container
If the second undocumented parameter is present and set to true, then an animated zoom is performed if continuous zoom is enabled.
updateCurrentTab(modifier function, onupdate function) Updates the currently selected info window tab, causing a resize of the info window, without repositioning. The modifier function is used to modify the currently selected tab and is passed a GInfoWindowTab as an argument.
updateInfoWindow(tabs, onupdate function) Updates the content of the currently open info window, without repositioning. The info window is resized to fit the new content.
EventReturns
addmaptypemaptype
addoverlayoverlay
clearoverlaysnone
clickoverlay, latlng
dblclickoverlay, latlng (the first parameter is always null)
dragnone
dragendnone
dragstartnone
infowindowbeforeclosenone
infowindowclosenone
infowindowopennone
loadnone
maptypechangednone
movenone
moveendnone
movestartnone
mousemovelatlng
mouseoutlatlng
mouseoverlatlng
removemaptypemaptype
removeoverlayoverlay
resizeundocumentednone
singlerightclicklatlng, src, overlay
zoomendoldZoom, newZoom
zoomingundocumentednone
zoomstartundocumenteddirection (+1=in, -1=out), latlng pivot, bool recentering


openInfoWindow() Methods

There are a set of 15 methods for opening info windows, 5 methods each for GMap(), GMap2() and GMarker() objects. Some of the methods are inherited by the GMap() class from the GMap2() class, and some are overwritten with different parameters.

I'm documenting them all in one chunk here, rather than repeating all the details 15 times.

The different methods take slightly different parameters. Chosen from this list:
point GLatLng() Geographical location.
htmlElem HTML DOM element Info Window contents expressed as a DOM Element.
htmlStr HTML string Info Window contents expressed as a string.
tabElemArray array of GInfoWindowTab()s One for each tab, with a HTML DOM element in the contentElem
tabStrArray array of GInfoWindowTab()s One for each tab, with a HTML string in the contentElem
offset GSize() (Optional) Pixel offset from the point.
selectedTab integer (Optional) Specifies the number of the tab to be initially selected. Counting from zero. If omitted, tab zero is selected.
maxWidth integer (Optional) (Possibly) Maximum width that can be considered for info window contents size calculations.
If omitted, the screen.width is used.
The height calculations go wrong if this is set less than 217, the minimum infoWindow contents width.
openFn function (Optional) Function to be called when the info window opens.
closeFn function (Optional) Function to be called when the info window closes.
optsanonymous object(Optional) may contain some or all of the following object properties:
  • selectedTab: integer
  • maxWidth: integer
  • noCloseOnClick: boolean
  • onOpenFn: function
  • onCloseFn: function
  • zoomLevel: integer
  • mapType: GMapType()
  • maxContent: string
  • maxTitle: string
  • pixelOffset: GSize()
  • undocumented maxHeight: integer
  • undocumented autoScroll: boolean
  • undocumented onPrepareOpenFn: function
  • undocumented onBeforeCloseFn: function
  • undocumented suppressMapPan: boolean
  • undocumented limitSizeToMap: boolean
  • undocumented contentSize: GSize
  • undocumented noClearOnClose: boolean
  • undocumented noCloseBeforeOpen: boolean
  • undocumented onCloseClick:function
  • undocumented onMaximizeClick:function
  • undocumented onRestoreClick:function
for example: {pixelOffset:new GSize(32,5), maxWidth: 540}

Note: The onOpenFn, onPrepareOpenFn, onCloseFn and onBeforeCloseFn options only work for the map methods. When using marker.infoWindowOpen*(), those options are hijacked and replaced by calls to API internal functions that throw the corresponding events on the marker.

zoom integer (Optional) Zoom level for the contained map.
maptype GMapType() (Optional) Map type for the contained map

The individual methods take the following parameters:

GMap2().openInfoWindow(point,htmlElem, opts)
GMap2().openInfoWindowHtml(point, htmlStr, opts)
GMap2().openInfoWindowTabs(point, tabElemArray, opts)
GMap2().openInfoWindowTabsHtml(point, tabStrArray, opts)

GMap().openInfoWindow(point, htmlElem, offset, openFn, closeFn)
GMap().openInfoWindowHtml(point, htmlStr, offset, openFn, closeFn)
GMap().openInfoWindowTabs(point, tabElemArray, opts)
GMap().openInfoWindowTabsHtml(point, tabStrArray, opts)

marker.openInfoWindow(htmlElem, opts)
marker.openInfoWindowHtml(htmlStr, opts)
marker.openInfoWindowTabs(tabElemArray, opts)
marker.openInfoWindowTabsHtml(tabStrArray, opts)

GMap2().showMapBlowup(point, opts)
GMap().showMapBlowup(point, zoom, maptype, offset, openFn, closeFn)
marker.showMapBlowup(opts)

In addition there is GMap().openInfoWindowXslt() and marker.openInfoWindowXslt(). These methods do nothing. They do not open an info window. They exist only so that maps written using this documented v1 syntax don't crash.


GMapType()

Holds the information about a map type.

Constructor new GMapType(tileLayers, projection, name, opts)
parameters
tilelayersAn array of GTileLayer() objects
projectionA reference to the projection function, e.g. new GMercatorProjection(22)
nameThe long name for the map type
opts(optional)An anonymous object which may contain more information

opts If you want to set up any of the other internal properties of your GMapType() you have to bundle them into an anonymous object. The constructor copies the named properties of this anonymous object into the hidden internal properties of the GMapType.
 
propertypurposedefault
shortNameName to be used if GMapTypeControl() is in "tiny" mode""
urlArgA string which can be used to identify the map type. It can be used to link copyright information to map types."c"
maxResolutionMaximum zoom level supportedThe highest zoom level supported by any of the GTileLayers
minResolutionMinimum zoom level supportedThe lowest zoom level supported by any of the GTileLayers
textColorthe text colour to by used for any text drawn above the map (e.g. the copyright text, and the numbers in GScaleControl). Can use a named colour, like "black", or a hex value like "#ffffff"."black"
linkColorthe text colour to be used for any links that are drawn above the map (e.g. "Terms of Use"). It can use a named colour, like "black", or a hex value like "#ffffff"."#7777cc"
tileSizean integer that specifies the size of the tiles. Tiles are always square.256
errorMessgea string containing the error message to be used if no tile can be served.""
alta string containing the tooltip text to be used in the GMapTypeControl.""
radiusRadius of planet (not currently used) defaults to 6378137""
enableZoomLevelLimits????""
methods
getBoundsZoomLevel(latlngbounds,viewsize)Returns the highest supported zoom level for which the latlngbounds will fit in the specified viewsize.
getErrorMessage()Returns a string containing the error message to be used if no tile can be served.
getLinkColor()Returns the text colour to be used for any links that are drawn above the map (e.g. "Terms of Use"). It can use a named colour, like "black", or a hex value like "#ffffff".
getMaximumResolution(a)Returns the number of the highest Zoom level that the map type supports. The function is coded to accept an optional parameter, but that parameter is always void.
getMinimumResolution()Returns the number of the lowest Zoom level that the map type supports.
getName(bool)Returns the name to be used in GMapTypeControl(). If the optional parameter is present and true, returns the short name to be used on tiny maps.
getProjection()Returns the GProjection() object associated with the map type.
getSpanZoomLevel(latlng,latlng,viewsize)(Possibly) Returns the highest supported zoom level for which a map centred at the first latlng will have a span greater than or equal to that specified by the second latlng. If no supported zoom level achieves that, it will return zero, even if that's not supported by this map type.
getTextColor()Returns the text colour to by used for any text drawn above the map (e.g. the copyright text, and the numbers in GScaleControl). Can use a named colour, like "black", or a hex value like "#ffffff".
getTileLayers()Returns an array of GTileLayer() objects. A map type can have more than one layer (as does G_HYBRID_MAP)
getTileSize()Returns an integer that specifies the size of the tiles. Tiles are always square.
getUrlArg()Returns a (one-character) string which can be used to identify the map type. It is used to identify the map type in the &t= parameter of Google Local.
getAlt()Returns the alternate text associated with the map type button for this map type


GMapTypeControl()

A GControl() structure that manages map type switching, typically in the top right corner of the map.
Has all the properties and methods of the GControl() class.

It additionally accepts an optional parameter.
parameters
a bool If present and true, the control will use short names in the map type buttons.


GMarker()

A GMarker() object plots an icon at a specified point on a map.

Constructor format 1 new GMarker(point, icon, inert) deprecated
point GLatLng() Specifies the geographical location where the marker is to be plotted.
icon GIcon() (Optional) Icon to be plotted. If omitted, G_DEFAULT_ICON is used.
inert bool (Optional) If true, the .clickable property is set false.

Constructor format 2 new GMarker(point, opts)
point GLatLng() Specifies the geographical location where the marker is to be plotted.
opts (optional)Anonymous object may contain more information

opts You can use either format for the GMarker constructor. The "draggable" option can only be set using format 2.

E.g. var marker = new GMarker(point, {icon: myIcon, draggable:true});
 
propertytypepurpose
bouncybooleanSet false to disable the silly bounce animation of draggable markers.
bounceGravity floatControls the downward acceleration of a released draggable marker
bounceTimeout integer undocumented Controls the time between animation frames of a released draggable marker (and hence the velocity)
iconGIcon()Icon to be plotted. If omitted, G_DEFAULT_ICON is used.
clickableboolfalse to make the marker inert
draggablebooltrue to make the marker draggable
dragCrossMovebooltrue to make the cross move downwards rather than the icon move upwards during dragging.
titlestringtooltip text
idstringundocumented sets the marker.id property
descriptionstringundocumented I don't know what this does.
namestringundocumented I don't know what this does.
zIndexProcessfunction(GMarker) returning an integer Instead of having the API determine the way that one marker overlays another, you can associate a zIndexProcess with a marker which returns the value that that API will use for the z-index.
See Setting the z-index of markers

A GMarker() has no accessible properties

methods
copy()undocumented Returns a new GMarker that is a copy of this one.
disableDragging()Disables marker dragging.
dragabble()Returns true if this marker was created as a draggable marker
dragging()undocumented returns true if this marker is currently being dragged
draggingEnabled()Returns true if dragging is enabled on this marker
enable Dragging()Enables dragging, if the marker was created as a draggable marker
getIcon()Returns the GIcon() associated with the marker
getPoint()Returns the GLatLng() where the marker is located
getLatLng() Returns the GLatLng() where the marker is located [an alias of getPoint().]
hide() Hides the marker
initialize(map)Used by map.addOverlay() to set up the marker.
isHidden()Returns true if the marker is hidden
openInfoWindow(a,b)Opens the info window, see above for parameters
openInfoWindowHtml(a,b)Opens the info window, see above for parameters
openInfoWindowTabs(a,b)Opens the info window, see above for parameters
openInfoWindowTabsHtml(a,b)Opens the info window, see above for parameters
redraw(bool)If the optional parameter is present and true, the marker is redrawn.
remove()Destroys the images[ ]. Used by map.removeOverlay() to recover memory.
setImage(filename) Changes the marker image.
setPoint(latlng)Changes the location of the marker, recalculates the z-index and redraws it.
setLatLng(latlng)Changes the location of the marker, recalculates the z-index and redraws it. [an alias of setPoint().]
show() Makes a hidden marker visible
showMapBlowup(a,b)Opens the info window with a blowup maplet, see above for parameters
getTitle()Returns the {title} associated with this marker.
closeInfoWindow()Closes the info window only if the info window is associated with this marker.
bindInfoWindow(node,options)See below.
bindInfoWindowHtml(text,options)See below.
bindInfoWindowTabs(tabElemArray,options)See below.
bindInfoWindowTabsHtml(tabStrArray,options)See below.

The marker.bindInfoWindow*() methods create GEvent listeners that perform the corresponding marker.openInfoWindow*() calls when the marker is clicked.

E.g.
  marker.bindInfoWindowHtml("hello world",{maxWidth:500})
seems to be shorthand for

GEvent.addListener(marker,"click", function() {
  marker.openInfoWindowHtml("hello world",{maxWidth:500});
});

There are differences in the timing of the evaluation of the variables. You don't need a createMarker() function to hold function closure on the .bindInfoWindow() parameters.


GMarkerManager()

A GMarkerManager() can be used to manage large numbers of markers efficiently as long as you're careful to only have a modest number of markers visible in the viewport at any one time.

Constructor new GMarkerManager(map, options)

properties
There are no accessible properties

Options
borderPadding integer Specifies, in pixels, the extra padding outside the map's current viewport monitored by a manager. Increasing the value makes it more likely that a marker will be already rendered when the map pans, but decreases the efficiency of redrawing the markers (e.g. when the zoom level changes).
maxZoom integer The maximum zoom level to be managed. Defaults to the max zoom of the map type that is current when the manager is created.
trackMarkers boolean Automatically refresh the marker display when a managed marker changes position with .setPoint().

methods
addMarker(marker, minzoom, maxzoom)Adds a marker to be displayed when the zoom number is in the specified range.
addMarkers(markerArray, minzoom, maxzoom)Adds an array of markers to be displayed when the zoom number is in the specified range.
getMarkerCount(zoom)Returns the number of managed markers for the specified zoom level.
refresh()Redraws the managed markers.


GMenuMapTypeControl()

A GControl() structure that manages map type switching, typically in the top right corner of the map. Has all the properties and methods of the GControl() class.

Similar to GMapTypeControl() except that it uses a drop down menu instead of separate buttons.

It additionally accepts two optional parameters.
parameters
a bool If present and true, the control will use short names in the map type buttons.
b bool undocumented If present and true, the control will have an extra border.


GMercatorProjection()

Handles the translation between geographical locations and pixel positions for a map type that uses Mercator maps.

The GMercatorProjection() constructor and methods assume a tile size of 256 by 256. The getTileSize() information from the GMapType() is not used.

Constructor
new GMercatorProjection(maxResolution)

properties
There are no accessible properties

methods
fromLatLngToPixel(latlng,zoom)Returns a GPoint() containing the pixel position (in the tilespace) corresponding to the geographical location.
fromPixelToLatLng(point,zoom,nofix)Returns a GLatLng() containing the geographical location corresponding to the point in tilespace. If the optional nofix parameter is not present, out of range latitudes are fixed to +-90, and out of range longitudes are wrapped around the globe into the range +-180.
getWrapWidth(zoom) Returns the wrap width of the tile space in pixels.
tileCheckRange(point,zoom,tilesize)Returns true if point.y is within the tilespace for the specified zoom level, and wraps point.x around the globe to a value that is within the tilespace.
If point.y is outside the tilespace, then it returns false without wrapping point.x.
The tilespace is a square array of tiles that cover the Earth.
The Mercator projection never actually reaches the poles. In this implementation, the mapping stops at about latitude 85.0511.
The pixel represented by GPoint(0,0) always represents the geographical location GLatLng(85.0511, -180).
At zoom level 0, there is one tile, tileBounds[0] is 1, pixelOrigo[0] is GPoint(128,128) - the distance from a corner of that tile to the centre.
At zoom level 1, there are four tiles in a 2*2 grid, tileBounds[1] is 2, pixelOrigo[1] is GPoint(256,256).
At zoom level 17, there are 17,179,869,184 tiles in a 131072*131072 grid, tileBounds[17] is 131072, pixelOrigo[17] is GPoint(16777216, 16777216).


GOverlay()

This class holds the common methods that are inherited by GMarker(), GPolyline() , GPolygon(), GInfoWindow(), GGeoXml(), GTrafficOverlay(), GGroundOverlay() and GTileLayerOverlay()

This class can also be used to create custom overlays, in which case you may need to create your own copies of the methods.

methods
copy()Returns a new GOverlay that is a copy of this one.
hide()Hides the overlay
initialize(map)Used by map.addOverlay() to set up the overlay.
redraw(bool)If the optional parameter is present and true, the overlay is redrawn.
remove()Used by map.removeOverlay() to recover memory.
show()Shows the overlay
Static Method
GOverlay.getZIndex(lat)Returns a z-index value for a given latitude. It computes a z index such that overlays further south are on top of overlays further north, thus creating the 3D appearance of marker overlays.


GOverviewMapControl()

A GControl() object providing an overview map
Has all the properties and methods of the GControl() class plus the methods described below.
parameters
a GSize() undocumented Specifies the size of the overview map.
methods
getOverviewMap()undocumented Returns a pointer to the overview map div.
hide(instant)Reduces the overview map to a small icon.
If the undocumented parameter is set true then the overview closes instantly, otherwise there's a short animation.
show(instant)Expands a hidden overview map. If the undocumented parameter is set true then the overview opens instantly, otherwise there's a short animation.

GPoint()

Identifies a pixel position or a pixel offset.

Constructor new GPoint(x,y)

properties
xhorizontal position
yvertical position
methods
equals(point)Returns true if the two points are equal.
toStringReturns a string in the format "(123,123)"

GPolyline()

Describes a vector polyline.

Constructor new GPolyline(points, color, weight, opacity, opts)

parameters
pointsAn array of GLatLng() or GPoint() objects
colorString: the colour of the line in the format "#ffffff"
weightInteger: the width of the line
opacityFloat: the opacity of the line in the range 0.0 to 1.0
optsObject Literal: A set of GPolylineOptions

options
idundocumented I don't know what this does.
mapsdtundocumented I don't know what this does.
nameundocumented I don't know what this does.
geodesic When set true, a geodesic line is drawn instead of a straight line on the screen.
clickable When set false the clicks drop through to the underlying map.

properties
undocumented
color The colour of the line
opacity The opacity of the line
weight The width of the line
If you change any of the properties, call the .redraw(true) method to cause the changes to take effect.

methods
copy()Returns a new GPolyline that is a copy of this one.
getVertex(N)Returns a GLatLng() object specifying the location of the Nth point.
getVertexCount()Returns the number of points in the polyline.
initialize(map)Used by map.addOverlay() to set up the polyline.
redraw()The polyline is redrawn. [Prior to V2.101 you had to use .redraw(true)]
remove()Used by map.removeOverlay() to recover memory.
supportsHide()Returns true or false indicating whether the overlay supports .hide(), .show() and .isHidden()
Currently true if SVG or VML is used to draw the graphic, and false otherwise.
hide() Hides the polyline
show() Shows the polyline
isHidden() returns true if the polyline is hidden
getLength() Returns the length of the polyline in metres
getBounds(v1,v2) Returns the bounds for the polyline as a GLatLngBounds. The undocumented optional parameters can be used to specify the vertex numbers of a section of the polyline.

defaults
If you omit the colour, weight or opacity, the default values will be used: "#0000ff", 5, 0.45

Static methods
fromEncoded(code,opts)Creates a polyline from an encoded string. See The official documentation

GPolygon()

Describes a filled polygon.

Constructor new GPolygon(points, strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity, opts)

parameters
pointsAn array of GLatLng() or GPoint() objects
strokeColorString: the colour of the boundary in the format "#ffffff"
strokeWeightInteger: the width of the boundary
strokeOpacityFloat: the opacity of the boundary in the range 0.0 to 1.0
fillColorString: the colour of the fill in the format "#ffffff"
fillOpacityFloat: the opacity of the fill in the range 0.0 to 1.0
optsObject Literal: A set of GPolygonOptions

options

idundocumented I don't know what this does.
nameundocumented I don't know what this does.
mapsdtundocumented I don't know what this does.
outlineundocumentedBoolean: set false to switch off the boundary
clickable When set false the clicks drop through to the underlying map.

properties
undocumented
colorThe colour of the polygon fill
opacityThe opacity of the polygon fill
outlineBoolean: set to false to switch off the boundary
If you change any of the properties, call the .redraw(true) method to cause the changes to take effect.

methods
copy()Returns a new GPolygon that is a copy of this one.
getVertex(N)Returns a GLatLng() object specifying the location of the Nth point.
getVertexCount()Returns the number of points in the polyline.
initialize(map)Used by map.addOverlay() to set up the polyline.
redraw(bool)If the optional parameter is present and true, the polygon is redrawn.
remove()Used by map.removeOverlay() to recover memory.
supportsHide()Returns true or false indicating whether the overlay supports .hide(), .show() and .isHidden()
Currently true if SVG or VML is used to draw the graphic, and false otherwise.
hide() Hides the polygon
show() Shows the polygon
isHidden() returns true if the polygon is hidden
getArea() Returns the area of the polygon in square metres.
getBounds() Returns the bounds of the polygon as a GLatLngBounds

defaults
Although GPolygon defines defaults for strokeWeight and fillColour, it never uses them.

If you omit the strokeWeight, the stroke is not performed.

If you omit the fillColor, GPolygon sets the fill colour to the default value, "#0055ff", but then doesn't perform the fill.

The default fillOpacity is 0.25.

The defaults for strokeColour and strokeOpacity are the same as those for GPolyline: "#0000ff" and 0.45

Static methods
fromEncoded(code,opts) Creates a polygon from an encoded string.

GProjection()

This class provides a general structure for projection calculations. It is only used internally by GMercatorProjection() since that's the projection system that Google maps use.

The methods provided by GProjection() are empty stubs. Any real GProjection() object would have to overwrite them with its own methods that perform the relevant calculations.

It is possible to write your own GProjection() instance that uses a non-Mercator projection, such as Gall-Peters or Mollweide, or to write a flat projection for mapping non-spherical domains by writing suitable code to replace the method stubs.
methods
fromLatLngToPixel(latlng,zoom)Stub: Throws a an error "Required interface method not implemented"
fromPixelToLatLng(point,zoom,nofix)Stub: Throws a an error "Required interface method not implemented"
getWrapWidth(zoom)Returns Infinity.
tileCheckRange(point,zoom,tilesize)Returns true.


GRoute()

A GDirections() object can contain one or more routes, an additional route for each additional waypoint. The GRoute() object describes information specific to one route. There is no GRoute() constructor, you can only obtain a GRoute() by using GDirections.getRoute(n).

methods
getDistance()returns an Object that contains the distance information
.getDistance().html is a HTML string that describes the distance in suitable units
.getDistance().meters is a number indicating the distance in metres
getDuration()returns an Object that contains the duration information
.getDuration().html is a HTML string that describes the duration in suitable units
.getDuration().seconds is a number indicating the estimated duration in seconds
getEndGeocodeReturns geocode information for the end point
getEndLatLngReturns a GLatLng object specifying the end point of the actual polyline.
getNumStepsReturns the number of steps in this route
getStartGeocodeReturns geocode information for the start point
getStep(n)Returns a GStep() object
getSummaryHtml()returns a HTML string containing something like "790 mi (about 12 hours 28 mins)"


GScaleControl()

A GControl() structure that displays a map scale, typically in the bottom left corner of the map.
Has all the properties and methods of the GControl() class, and additionally has the properties shown below.

If _mPreferMetric is set to true, then the metric scale is on top instead of below the feet/miles scale.

It additionally accepts an optional parameter.
parameters
a integer undocumented (Optional) Max length of the scale in pixels.
properties
barA div containing part of the graphics
capA div containing part of the graphics
containerA div containing all the other divs
fpsBarA div containing part of the graphics
fpsLblA div containing the text for non-metric measurements
mapA reference to the map that contains this Scale
maxLengthMax length of the scale in pixels
metricBarA div containing part of the graphics
metricLblA div containing the text for metric measurements


GScreenOverlay

Places an image on the screen which remains in a fixed position. It does not move when the map drags.

The overlay does not capture mouse clicks. You can drag the map through the overlay. You can't, however, click on m