Google Maps API Version 2 Reference
If you only want to use the map to display your content, then
you need to know these classes, types, and functions:
If you want to extend the functionality of the maps API by
implementing your own controls, overlays, or map types, then you
also need to know these classes and types:
Instantiate class GMap2 in order to
create a map. This is the central class in the API. Everything
else is auxiliary.
Constructor
| Constructor |
Description |
| GMap2(container, opts?) |
Creates a new map inside of the given HTML container, which
is typically a DIV element. If no set of map types
is given in the optional argument opts.mapTypes, the
default set G_DEFAULT_MAP_TYPES is used. If no size
is given in the optional argument opts.size, then the
size of the container is used. If opts.size
is given, then the container element of the map is resized
accordingly. See class GMapOptions. |
Methods
Configuration
| Methods |
Return Value |
Description |
| enableDragging() |
none |
Enables the dragging of the map (enabled by default). |
| disableDragging() |
none |
Disables the dragging of the map. |
| draggingEnabled() |
Boolean |
Returns true iff the dragging of the map is
enabled. |
| enableInfoWindow() |
none |
Enables info window operations on the map (enabled by
default). |
| disableInfoWindow() |
none |
Closes the info window, if it is open, and disables the
opening of a new info window. |
| infoWindowEnabled() |
Boolean |
Returns true iff the info window is
enabled. |
| enableDoubleClickZoom() |
none |
Enables double click to zoom in and out (disabled by default). (Since 2.58) |
| disableDoubleClickZoom() |
none |
Disables double click to zoom in and out. (Since 2.58) |
| doubleClickZoomEnabled() |
Boolean |
Returns true iff double click to zoom is enabled. (Since 2.58) |
| enableContinuousZoom() |
none |
Enables continuous smooth zooming for select browsers (disabled by default). (Since 2.58) |
| disableContinuousZoom() |
none |
Disables continuous smooth zooming. (Since 2.58) |
| continuousZoomEnabled() |
Boolean |
Returns true iff continuous smooth zooming is enabled. (Since 2.58) |
Controls
| Methods |
Return Value |
Description |
| addControl(control, position?) |
none |
Adds the control to the map. The position on the map is
determined by the optional position argument. If
this argument is absent, the default position of the control is
used, as determined by the
GControl.getDefaultPosition() method. A control
instance must not be added more than once to the map. |
| removeControl(control) |
none |
Removes the control from the map. It does nothing if the
control was never added to the map. |
| getContainer() |
Node |
Returns the DOM object that contains the map. Used by
GControl.initialize(). |
Map Types
| Methods |
Return Value |
Description |
| getMapTypes() |
Array of GMapType |
Returns the array of map types registered with this map. |
| getCurrentMapType() |
GMapType |
Returns the currently selected map type. |
| setMapType(type) |
none |
Selects the given new map type. The type must be known to
the map. See the constructor, and the method
addMapType(). |
| addMapType(type) |
none |
Adds a new map type to the map. See section GMapType for how to define
custom map types. |
| removeMapType(type) |
none |
Removes the map type from the map. Will update the set of
buttons displayed by the GMapTypeControl and fire
the removemaptype event. |
Map State
| Methods |
Return Value |
Description |
| isLoaded() |
Boolean |
Returns true iff the map was initialized by
setCenter() since it was created. |
| getCenter() |
GLatLng |
Returns the geographical coordinates of the center point of
the map view. |
| getBounds() |
GLatLngBounds |
Returns the the visible rectangular region of the map view
in geographical coordinates. |
| getBoundsZoomLevel(bounds) |
Number |
Returns the zoom level at which the given rectangular region
fits in the map view. The zoom level is computed for the
currently selected map type. If no map type is selected yet, the
first on the list of map types is used. |
| getSize() |
GSize |
Returns the size of the map view in pixels. |
| getZoom() |
Number |
Returns the current zoom level. |
Modify the Map State
| Methods |
Return Value |
Description |
| setCenter(center, zoom?,
type?) |
none |
Sets the map view to the given center. Optionally, also sets
zoom level and map type. The map type must be known to the
map. See the constructor, and the method
addMapType(). This method must be called first
after construction to set the initial state of the map. It is
an error to call other operations on the map after
construction. |
| panTo(center) |
none |
Changes the center point of the map to the given point. If
the point is already visible in the current map view, change the
center in a smooth animation. |
| panBy(distance) |
none |
Starts a pan animation by the given distance in pixels. |
| panDirection(dx, dy) |
none |
Starts a pan animation by half the width of the map in the
indicated directions. +1 is right and down,
-1 is left and up, respectively. |
| setZoom(level) |
none |
Sets the zoom level to the given new value. |
| zoomIn() |
none |
Increments zoom level by one. |
| zoomOut() |
none |
Decrements zoom level by one. |
| savePosition() |
none |
Stores the current map position and zoom level for later
recall by returnToSavedPosition(). |
| returnToSavedPosition() |
none |
Restores the map view that was saved by
savePosition(). |
| checkResize() |
none |
Notifies the map of a change of the size of its
container. Call this method after the size of the container DOM
object has changed, so that the map can adjust itself to fit the
new size. |
Overlays
| Methods |
Return Value |
Description |
| addOverlay(overlay) |
none |
Adds an overlay to the map and fires the
addoverlay event. |
| removeOverlay(overlay) |
none |
Removes the overlay from the map. If the overlay was on the
map, it fires the removeoverlay event. |
| clearOverlays() |
none |
Removes all overlay from the map, and fires the
clearoverlays event. |
| getPane(pane) |
Node |
Returns a DIV that holds the object in the layer identified
by pane. Used by GOverlay instances in
method GOverlay.initialize() instances to draw
themselves on the map |
Info Window
| Methods |
Return Value |
Description |
| openInfoWindow(point, node,
opts?) |
none |
Opens a simple info window at the given point. Pans the map such
that the opened info window is fully visible. The content of the
info window is given as a DOM node. |
| openInfoWindowHtml(point, html,
opts?) |
none |
Opens a simple info window at the given point. Pans the map such
that the opened info window is fully visible. The content of the
info window is given as HTML text. |
| openInfoWindowTabs(point, tabs, opts?) |
none |
Opens a tabbed info window at the given point. Pans the map such
that the opened info window is fully visible. The content of the
info window is given as DOM nodes. |
| openInfoWindowTabsHtml(point, tabs, opts?) |
none |
Opens a tabbed info window at the given point. Pans the map such
that the opened info window is fully visible. The content of the
info window is given as HTML text. |
| showMapBlowup(point, opts?) |
none |
Opens an info window at the given point that contains a
closeup view on the map around this point. |
| closeInfoWindow() |
none |
Closes the currently open info window. |
| getInfoWindow() |
GInfoWindow |
Returns the info window object of this map. If no info
window exists yet, it is created, but not displayed. This
operation is not influenced by
enableInfoWindow(). |
Coordinate Transformations
| Methods |
Return Value |
Description |
| fromLatLngToDivPixel(latlng) |
GPoint |
Computes the pixel coordinates of the given geographical
point in the DOM element that holds the draggable map. You need
this method to position a custom overlay when you implement the
GOverlay.redraw() method for a custom overlay. |
| fromDivPixelToLatLng(pixel) |
GLatLng |
Computes the geographical coordinates from pixel coordinates
in the div that holds the draggable map. You need this when you
implement interaction with custom overlays. |
| fromContainerPixelToLatLng(pixel) |
GLatLng |
Computes the geographical coordinates of the point at the
given pixel coordinates in the DOM element that contains the map
on the page. You need this when you implement interaction of
custom controls with the map. |
Events
| Events |
Arguments |
Description |
| addmaptype |
type |
This event is fired when a map type is added to the map. |
| removemaptype |
type |
This event is fired when a map type is removed from the map. |
| click |
overlay, point
|
This event is fired when the map is clicked with the
mouse. If the click was on a marker, then the marker is passed
to the event handler in the overlay argument, and a
click event is also fired on the marker. Otherwise,
the geographical coordinates of the point that was clicked are
passed in the point argument. |
| movestart |
none |
This event is fired when the map view starts changing. This can be
caused by dragging, in which case a dragstart event
is also fired, or by invocation of a method that changes the map
view. |
| move |
none |
This event is fired, possibly repeatedly, while the map
view is changing. |
| moveend |
none |
This event is fired when the change of the map view ends. |
| zoomend |
oldLevel, newLevel
|
This event is fired when the map reaches a new zoom
level. The event handler receives the previous and the new zoom
level as arguments. |
| maptypechanged |
none |
This event is fired when another map type is selected. |
| infowindowopen |
none |
This event is fired when the info window opens. |
| infowindowclose |
none |
This event is fired when the info window closes. If a
currently open info window is reopened at a different point
using another call to openInfoWindow*(), then
infowindowclose will fire first. |
| addoverlay |
overlay |
This event is fired when a single overlay is added to the
map by the method addOverlay(). The new overlay is
passed as an argument overlay to the event
handler. |
| removeoverlay |
overlay |
This event is fired when a single overlay is removed by the
method removeOverlay(). The overlay that was
removed is passed as an argument overlay to the event
handler. |
| clearoverlays |
none |
This event is fired when all overlays are removed at once
by the method clearOverlays(). |
| mouseover |
latlng |
This event is fired when the user moves the mouse over the
map from outside the map. |
| mouseout |
latlng |
This event is fired when the user moves the mouse off the
map. |
| mousemove |
latlng |
This event is fired when the user moves the mouse inside the
map. |
| dragstart |
none |
This event is fired when the user starts dragging the map. |
| drag |
none |
This event is repeatedly fired while the user drags the
map. |
| dragend |
none |
This event is fired when the user stops dragging the map. |
| load |
none |
This event is fired when the map setup is complete, and isLoaded()
would return true. This means position, zoom, and map type are all
initialized, but tile images may still be loading. (Since 2.52) |
This class represents optional arguments to the
GMap2 constructor. It has no constructor, but is
instantiated as object literal.
Properties
| Properties |
Type |
Description |
| size |
GSize |
Sets the size in pixels of the map. The container that is
passed to the map constructor will be resized to the given
size. By default, the map will assume the size of its
container. |
| mapTypes |
Array of GMapType |
Array of map types to be used by this map. By default,
G_DEFAULT_MAP_TYPES is used. You can use this
option to restrict the set of predefined map types that is
displayed on the map, or to pass your own map types to the
map. See also GMap2.addMapType(). |
| draggableCursor |
String |
The cursor to display when the map is draggable. (Since 2.59) |
| draggingCursor |
String |
The cursor to display while dragging the map. (Since 2.59) |
These constants define the layering system that is
used by overlay to display themselves on the map. There are
different layers for icons, shadows, the info window, the shadow on
the info window, and transparent mouse event catching objects.
You need to use this type if you subclass from
GOverlay.
Constants
| Constants |
Description |
| G_MAP_MAP_PANE |
This pane is still below the shadows of the markers,
directly on top of the map. It contains for instance the
polylines. |
| G_MAP_MARKER_SHADOW_PANE |
This pane contains the shadows of the markers. It is below
the markers. |
| G_MAP_MARKER_PANE |
This pane contains the markers. |
| G_MAP_FLOAT_SHADOW_PANE |
This pane conatains the shadow of the info window. It is
above the G_MAP_MARKER_PANE, so that markers can be
in the shadow of the info window. |
| G_MAP_MARKER_MOUSE_TARGET_PANE |
This pane contains transparent elements that receive DOM
mouse events for the markers. Is is above the
G_MAP_FLOAT_SHADOW_PANE, so that markers in the
shadow of the info window can be clickable. |
| G_MAP_FLOAT_PANE |
This pane contains the info window. It is above everything
else on the map. |
Instantiate this class to add keyboard bindings to
a map. The key bindings are the same as for the maps application.
key
action
up, down, left, right
Moves the map continuously while the key is pressed. Two
keys can be pressed simultaneously in order to move
diagonally.
page down, page up, home, end
Pans the map by 3/4 its size in the corresponding direction,
with a nice animation. This corresponds to the arrow buttons in
the GLargeMapControl and the
GSmallMapControl.
+, -
Zooms one level in or out, respectively. This corresponds to
the + and - buttons in the GLargeMapControl and the
GSmallMapControl.
Constructor
| Constructor |
Description |
| GKeyboardHandler(map) |
Installs keyboard event handler for the map passed as argument. |
This interface is implemented by the
GMarker, GPolyline, GTileLayerOverlay
and GInfoWindow classes in the maps API library. You can
implement it if you want to display custom types of overlay objects
on the map. An instance of GOverlay can be put on the
map with the method GMap2.addOverlay(). The map will
then call the method GOverlay.initialize() on the
overlay instance to display itself on the map initially. Whenever
the map display changes, the map will call
GOverlay.redraw() so that the overlay can reposition
itself if necessary. The overlay instance can use the method
GMap2.getPane() to get hold of one or more DOM
container elements to attach itself to.
Constructor
| Constructor |
Description |
| GOverlay() |
This constructor creates dummy implementations for the
methods. Still, when inheriting from this class, your derived
class constructor should call this constructor for
completeness. |
Static Methods
| Static Methods |
Return Value |
Description |
| getZIndex(latitude) |
Number |
Returns a CSS 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. |
Abstract Methods
| Abstract Methods |
Return Value |
Description |
| initialize(map) |
none |
Called by the map after the overlay is added to the map
using GMap2.addOverlay(). The overlay object can
draw itself into the different panes of the map that can be
obtained using GMap2.getPane(). |
| remove() |
none |
Called by the map after the overlay is removed from the map
using GMap2.removeOverlay() or
GMap2.clearOverlays(). The overlay must remove
itself from the map panes here. |
| copy() |
GOverlay |
Returns an uninitialized copy of itself that can be added to
the map. |
| redraw(force) |
none |
Called by the map when the map display has changed. The
argument force will be true if the
zoom level or the pixel offset of the map view has changed, so
that the pixel coordinates need to be recomputed. |
GInfoWindow没有构造器。它由地图对象创建,并由它的方法GMap2.getInfoWindow()访问。
方法
| 方法 |
返回值 |
Description |
| selectTab(index) |
无 |
选择给定id的页。这跟直接点击相应页的效果一致。 |
| hide() |
无 |
隐藏信息窗口。注意:这并不会关闭信息窗口。你可以用show()方法让信息窗口重新显示。 |
| show() |
无 |
如果信息窗口现在是隐藏的,则令其显示出来。 |
| isHidden() |
Boolean |
如果信息窗口是隐藏的则返回true。这包括了它被关闭的情况。 |
| reset(point, tabs, size, offset?, selectedTab?) |
无 |
重新设置信息窗口的状态。每个参数都可以为null,这样的话它的值就不会和当前的值有所改变。 |
| getPoint() |
GLatLng |
返回信息窗口指向的地理点。窗口的尖端指向这个点,偏差是点的偏移量。 |
| getPixelOffset() |
GSize |
返回信息窗口指向的地理点和地图上实际点之间的偏移量。 |
| getSelectedTab() |
Number |
返回当前选定页的id,从0开始计算的。 |
| getTabs() |
Array of GInfoWindowTabs |
返回信息窗口中页的数组。(2.59版以后) |
| getContentContainers() |
Array of Node |
返回用来保持信息窗口的页的DOM节点的数组。(2.59版以后) |
| enableMaximize() |
无 |
启用信息窗口的最大化功能。最大化的信息窗口会展开占据地图的几乎全部位置,显示由GInfoWindowOptions的属性maxContentmax和maxTitle所指定的内容。信息窗口打开同时,必须设置maxContent和maxTitle选项,这样enableMaximize()或者disableMaximize()才可能起作用。打开同时,已经设置maxContent和maxTitle选项的信息窗口默认启动最大化功能。(2.93以后)
|
| disableMaximize() |
无 |
禁用信息窗口的最大化功能。信息窗口打开同时,必须设置了maxContent和maxTitle选项。(2.93以后) |
| maximize() |
无 |
最大化信息窗口。信息窗口打开同时,必须设置了maxContent和maxTitle选项。(2.93以后) |
| restore() |
无 |
恢复信息窗口的默认状态(非最大化)。信息窗口打开同时,必须设置了maxContent和maxTitle选项。(2.93以后) |
Events
| Events |
Arguments |
Description |
| closeclick |
无 |
当信息窗口的关闭按钮被点击的时候该事件被触发。这个事件的处理函数可以通过调用GMap2.closeInfoWindow()实现关闭信息窗口的功能。 |
| maximizeclick |
无 |
信息窗口将要最大化的信号。(2.93以后) |
| maximizeend |
无 |
信息窗口最大化完成的信号。(2.93以后) |
| restoreclick |
无 |
信息窗口将要恢复默认状态的信号。(2.93以后) |
| restoreend |
无 |
信息窗口恢复默认状态完成的信号。(2.93以后) |
这个类的实例的数组可以作为方法
GMap2.openInfoWindowTabs(), GMap2.openInfoWindowTabsHtml(), GMarker.openInfoWindowTabs(),
和 GMarker.openInfoWindowTabsHtml()的参数tabs。如果这个数组的成员超过一个,那么信息窗口就会有分页。每个InfoWindowTab对象包含两个项目:content用来定义当分页被选择的时候显示的内容,label定义分页的标签。这些属性作为参数传递给构造器。对于openInfoWindowTabs() 方法,content是DOM节点。对于openInfoWindowTabsHtml()方法,content是包含HTML代码的字符串。
构造器
| 构造器 |
描述 |
| GInfoWindowTab(label, content) |
创建一个信息窗口页数据结构,用于传递给openInfoWindowTabs*()方法的tabs参数。 |
这个类的实例用于类GMap2和类GMarker的openInfoWindow(), openInfoWindowHtml(), openInfoWindowTabs(), openInfoWindowTabsHtml(),
and showMapBlowup()方法中的参数opts?中。这个类没有构造器。反之,这个类以javascript对象的形式实例化。
属性
就像类名说明的那样,所有的属性都是可选的。
| 属性 |
类型 |
描述 |
| selectedTab |
Number |
选择给定id的页,id从0开始计算。 |
| maxWidth |
Number |
信息窗口信息内容的宽度,单位为点阵。 |
| noCloseOnClick |
Boolean |
标明当点击地图而不是标记的时候,是否关闭信息窗口。如果设置为true,点击地图不会关闭信息窗口。默认值是false(2.83以后) |
| onOpenFn |
Function |
信息窗口打开显示内容后,函数被调用。 |
| onCloseFn |
Function |
信息窗口关闭后函数被调用。 |
| zoomLevel |
Number |
仅适用于showMapBlowup()方法。信息窗口中展示的地图的缩放级别。 |
| mapType |
GMapType |
仅适用于showMapBlowup()方法。信息窗口中展示的地图的地图类型。 |
| maxContent |
String |
指定信息窗口最大化后,展现的内容。可以是包含HTML代码的String,也可以是DOM节点。(2.93以后) |
| maxTitle |
String |
指定信息窗口最大化后的标题。(2.93以后) |
A GMarker marks a position on the
map. It implements the GOverlay interface and thus is
added to the map using the GMap2.addOverlay()
method.
A marker object has a point, which is
the geographical position where the marker is anchored on the map,
and an icon. If the icon is not set in the
constructor, the default icon G_DEFAULT_ICON is
used.
After it is added to a map, the info window of
that map can be opened through the marker. The marker object will
fire mouse events and infowindow events.
Constructor
| Constructor |
Description |
| GMarker(point, icon?, inert?) |
Creates a marker at point with
icon or the G_DEFAULT_ICON. If the
inert flag is true, then the marker is
not clickable and will not fire any events. (Deprecated since 2.50) |
| GMarker(point, opts?) |
Creates a marker at point with options
specified in GMarkerOptions. By default markers are
clickable & have the default icon
G_DEFAULT_ICON. (Since 2.50) |
Methods
Before these methods can be invoked, the marker
must be added to a map.
| Methods |
Return Value |
Description |
| openInfoWindow(content, opts?) |
none |
Opens the map info window over the icon of the marker. The
content of the info window is given as a DOM node. Only
option GInfoWindowOptions.maxWidth is
applicable. |
| openInfoWindowHtml(content, opts?) |
none |
Opens the map info window over the icon of the marker. The
content of the info window is given as a string that contains
HTML text. Only option
GInfoWindowOptions.maxWidth is applicable. |
| openInfoWindowTabs(tabs,
opts?) |
none |
Opens the tabbed map info window over the icon of the
marker. The content of the info window is given as an array of
tabs that contain the tab content as DOM nodes. Only
options GInfoWindowOptions.maxWidth and
InfoWindowOptions.selectedTab are applicable. |
| openInfoWindowTabsHtml(tabs, opts?) |
none |
Opens the tabbed map info window over the icon of the
marker. The content of the info window is given as an array of
tabs that contain the tab content as Strings that contain
HTML text. Only options
InfoWindowOptions.maxWidth and
InfoWindowOptions.selectedTab are applicable. |
| showMapBlowup(opts?) |
none |
Opens the map info window over the icon of the marker. The
content of the info window is a closeup map around the marker
position. Only options InfoWindowOptions.zoomLevel
and InfoWindowOptions.mapType are applicable. |
| getIcon() |
GIcon |
Returns the icon of this marker, as set by the
constructor. |
| getPoint() |
GLatLng |
Returns the geographical coordinates of the point at which
this marker is anchored, as set by the constructor or by
setPoint(). |
| setPoint(point) |
none |
Sets the geographical coordinates of the point at which this
marker is anchored. |
| enableDragging() |
none |
Enables the marker to be dragged and dropped around the map.
To function, the marker must have been initialized with
GMarkerOptions.draggable = true. |
| disableDragging() |
none |
Disables the marker from being dragged and dropped around the
map. |
| draggable() |
Boolean |
Returns true if the marker has been initialized via the
constructor using GMarkerOptions.draggable =
true. Otherwise, returns false.
|
| draggingEnabled() |
Boolean |
Returns true if the marker is currently enabled for the user
to drag on the map.
|
Events
All these events fire only if the marker is not
inert (see constructor).
| Events |
Arguments |
Description |
| click |
none |
This event is fired when the marker icon was clicked. Notice
that this event will also fire for the map, with the marker
passed as the first argument to the event handler there. |
| dblclick |
none |
This event is fired when the marker icon was
double-clicked. Notice that this event will not fire
for the map, because the map centers on double-click as a
hardwired behavior. |
| mousedown |
none |
This event is fired when the DOM mousedown event is fired on
the marker icon. Notice that the marker will stop the mousedown
DOM event, so that it doesn't cause the map to start
dragging. |
| mouseup |
none |
This event is fired for the DOM mouseup on the
marker. Notice that the marker will not stop the
mousedown DOM event, because it will not confuse the drag
handler of the map. |
| mouseover |
none |
This event is fired when the mouse enters the area of the
marker icon. |
| mouseout |
none |
This event is fired when the mouse leaves the area of the
marker icon. |
| infowindowopen |
none |
This event is fired when the info window of the map was
opened through this marker. |
| infowindowclose |
none |
This event is fired when the info window of the map that was
opened through this marker is closed again. This happens when
either the info window was closed, or when it was opened on
another marker, or on the map. |
| remove |
none |
This event is fired when the marker is removed from the
map, using GMap2.removeOverlay() or
GMap2.clearOverlays(). |
| dragstart |
none |
If the marker is enabled for dragging, this event is fired
when the marker dragging begins. |
| drag |
none |
If the marker is enabled for dragging, this event is fired
when the marker is being dragged. |
| dragend |
none |
If the marker is enabled for dragging, this event is fired
when the marker ceases to be dragged. |
Instances of this class are used in the
opts? argument to the constructor of the
GMarker class. There is no constructor for this
class. Instead, this class is instantiated as a javascript object
literal.
Properties
As the name of this class indicates, all
properties are optional.
| Properties |
Type |
Description |
| icon |
GIcon |
Chooses the Icon for this class. If not specified,
G_DEFAULT_ICON is used. (Since 2.50) |
| dragCrossMove |
Boolean |
When dragging markers normally, the marker floats up and
away from the cursor. Setting this value to true
keeps the marker underneath the cursor, and moves the cross
downwards instead. The default value for this option is
false. (Since 2.63) |
| title |
String |
This string will appear as tooltip on the marker, i.e. it
will work just as the title attribute on HTML
elements. (Since 2.50) |
| clickable |
Boolean |
Toggles whether or not the marker is clickable. Markers that
are not clickable or draggable are inert, consume less resources
and do not respond to any events. The default value for this
option is true, i.e. if the option is not
specified, the marker will be clickable. (Since 2.50) |
| draggable |
Boolean |
Toggles whether or not the marker will be draggable by
users. Markers set up to be dragged require more resources to
set up than markers that are clickable. Any marker that is
draggable is also clickable and bouncy by default. The default
value for this option is false. (Since 2.61) |
| bouncy |
Boolean |
Toggles whether or not the marker should bounce up and down
after it finishes dragging. The default value for this option is
false. (Since 2.61) |
| bounceGravity |
Number |
When finishing dragging, this number is used to define the
acceleration rate of the marker during the bounce down to
earth. The default value for this option is 1. (Since 2.61) |
This is a map overlay that draws a polyline on the
map, using the vector drawing facilities of the browser if they are
available, or an image overlay from Google servers otherwise.
Constructor
| Constructor |
Description |
| GPolyline(points, color?, weight?, opacity?) |
Creates a polyline from an array of vertices. The
color is given as a string that contains the color
in hexadecimal numeric HTML style, i.e. #RRGGBB. The
weight is the width of the line in pixels. The
opacity is given as a number between 0 and 1. The
line will be antialiased and semitransparent. |
Factory Methods
| Factory Methods |
Return Value |
Description |
| fromEncoded(color?, weight?,
opacity?, points,
zoomFactor, levels,
numLevels) |
GPolyline |
Creates a polyline from encoded strings of aggregated points
and levels. color is a string that contains a
hexadecimal numeric HTML style,
i.e. #RRGGBB. weight is the width of the line in
pixels. opacity is a number between 0 and 1.
points is a string containing the encoded latitude
and longitude coordinates. levels is a string
containing the encoded polyline zoom level
groups. numLevels is the number of zoom levels
contained in the encoded levels string.
zoomFactor is the magnification between adjacent
sets of zoom levels in the encoded levels
string. Together, these two values determine the precision of
the levels within an encoded polyline. The line
will be antialiased and semitransparent. (Since 2.63) |
Methods
| Methods |
Return Value |
Description |
| getVertexCount() |
Number |
Returns the number of vertices in the polyline. (Since 2.46) |
| getVertex(index) |
GLatLng |
Returns the vertex with the given index in the
polyline. (Since 2.46) |
Events
| Events |
Arguments |
Description |
| remove |
none |
This event is fired when the polyline is removed from the
map, using GMap2.removeOverlay() or
GMap2.clearOverlays(). |
An icon specifies the images used to display a
GMarker on the map. For browser compatibility reasons,
specifying an icon is actually quite complex. Note that you can use
the default Maps icon G_DEFAULT_ICON if you don't want
to specify your own.
Constructor
| Constructor |
Description |
| GIcon(copy?, image?) |
Creates a new icon object. If another icon is given in the
optional copy argument, its properties are copied,
otherwise they are left empty. The optional argument
image sets the value of the image
property. |
Constants
| Constants |
Description |
| G_DEFAULT_ICON |
The default icon used by markers. |
Properties
| Properties |
Type |
Description |
| image |
String |
The foreground image URL of the icon. |
| shadow |
String |
The shadow image URL of the icon. |
| iconSize |
GSize |
The pixel size of the foreground image of the icon. |
| shadowSize |
GSize |
The pixel size of the shadow image. |
| iconAnchor |
GPoint |
The pixel coordinate relative to the top left corner of the
icon image at which this icon is anchored to the map. |
| infoWindowAnchor |
GPoint |
The pixel coordinate relative to the top left corner of the
icon image at which the info window is anchored to this
icon. |
| printImage |
String |
The URL of the foreground icon image used for printed
maps. It must be the same size as the main icon image given by
image. |
| mozPrintImage |
String |
The URL of the foreground icon image used for printed maps
in Firefox/Mozilla. It must be the same size as the main icon
image given by image. |
| printShadow |
String |
The URL of the shadow image used for printed maps. It should
be a GIF image since most browsers cannot print PNG images. |
| transparent |
String |
The URL of a virtually transparent version of the foreground
icon image used to capture click events in Internet
Explorer. This image should be a 24-bit PNG version of the main
icon image with 1% opacity, but the same shape and size as the
main icon. |
| imageMap |
Array of Number |
An array of integers representing the x/y coordinates of the
image map we should use to specify the clickable part of the
icon image in browsers other than Internet Explorer. |
A GPoint represents a point on the
map by its pixel coordinates. Notice that in v2, it doesn't
represent a point on the earth by its geographical coordinates
anymore. Geographical coordinates are now represented by
GLatLng.
In the map coordinate system, the x
coordinate increases to the left, and the y coordinate
increases downwards.
Notice that while the two parameters of a
GPoint are accessible as properties x and
y, it is better to never modify them, but to create a new
object with different paramaters instead.
Constructor
| Constructor |
Description |
| GPoint(x, y) |
Creates a GPoint object. |
Properties
| Properties |
Type |
Description |
| x |
Number |
x coordinate, increases to the left. |
| y |
Number |
y coordinate, increases downwards. |
Methods
| Methods |
Return Value |
Description |
| equals(other) |
Boolean |
Returns true iff the other point has equal
coordinates. |
| toString() |
String |
Returns a string that contains the x and y coordinates, in
this order, separated by a comma. |
A GSize is the size in pixels of a
rectangular area of the map. The size object has two parameters,
width and height. Width is a difference in
the x-coordinate; height is a difference in the y-coordinate, of
points.
Notice that while the two parameters of a
GSize are accessible as properties width
and height, it is better to never modify them, but to
create a new object with different paramaters instead.
Constructor
| Constructor |
Description |
| GSize(width, height) |
Creates a GSize object. |
Properties
| Properties |
Type |
Description |
| width |
Number |
The width parameter. |
| height |
Number |
The height parameter. |
Methods
| Methods |
Return Value |
Description |
| equals(other) |
Boolean |
Returns true iff the other size has exactly
equal components. |
| toString() |
String |
Returns a string that contains the wdith and height
parameter, in this order, separated by a comma. |
GBounds is a rectangular area of the
map in pixel coordinates. Notice that a rectangle in
geographical coordinates is represented by a
GLatLngBounds object.
Constructor
| Constructor |
Description |
| GBounds(points) |
Constructs a rectangle that contains all the given
points. |
Properties
| Properties |
Type |
Description |
| minX |
Number |
The x coordinate of the left edge of the rectangle. |
| minY |
Number |
The y coordinate of the top edge of the rectangle. |
| maxX |
Number |
The x coordinate of the right edge of the rectangle. |
| maxY |
Number |
The y coordinate of the bottom edge of the rectangle. |
Methods
| Methods |
Return Value |
Description |
| toString() |
String |
Returns a string that contains the coordinates of the upper
left and the lower right corner points of the box, in this
order, separated by comma, surrounded by parentheses. |
| min() |
GPoint |
The point at the upper left corner of the box. |
| max() |
GPoint |
The point at the lower right corner of the box. |
| containsBounds(other) |
Boolean |
Returns true iff the other box is entirely
contained in this box. |
| extend(point) |
none |
Enlarges this box so that the point is also contained in
this box. |
| intersection(other) |
GBounds |
Returns the box by which this box overlaps the other
box. If there is no overlap, returns an empty box. |
GLatLng is a point in geographical
coordinates longitude and latitude.
Notice that although usual map projections
associate longitude with the x-coordinate of the map, and latitude
with the y-coordinate, the latitude cooridnate is always written
first, followed by the longitude, as it is custom in
cartography.
Notice also that you cannot modify the coordinates
of a GLatLng. If you want to compute another point, you
have to create a new one.
Constructor
| Constructor |
Description |
| GLatLng(lat, lng, unbounded?) |
Notice the ordering of latitude and longitude. If the
unbounded flag is true, then the
numbers will be used as passed, oterwise latitude will be
clamped to lie between -90 degrees and +90 degrees, and
longitude will be wrapped to lie between -180 degrees and +180
degrees. |
Methods
| Methods |
Return Value |
Description |
| lat() |
Number |
Returns the latitude coordinate in degrees, as a number
between -90 and +90. If the unbounded flag was
set in the constructor, this coordinate can be outside this
interval. |
| lng() |
Number |
Returns the longitude coordinate in degrees, as a number
between -180 and +180. If the unbounded flag was
set in the constructor, this coordinate can be outside this
interval. |
| latRadians() |
Number |
Returns the latitude coordinate in radians, as a number
between -PI/2 and +PI/2. If the unbounded flag was
set in the constructor, this coordinate can be outside this
interval. |
| lngRadians() |
Number |
Returns the longitude coordinate in radians, as a number
between -PI and +PI. If the unbounded flag was
set in the constructor, this coordinate can be outside this
interval. |
| equals(other) |
Boolean |
Returns true iff the other size has equal
components, within certain roundoff margins. |
| distanceFrom(other) |
Number |
Returns the distance, in meters, from this point to the
given point. The earth is approximated as a sphere, hence the
distance could be off by as much as 0.3%. |
| toUrlValue() |
String |
Returns a string that represents this point that is suitable
for use as a URL paramater value. It contains the latitude and
the longitide in degrees to 6 decimal digits, in this order,
separated by a comma, without whitespace. |
Properties
These properties exist for backwards compatibility
with v1 event handler functions only. They should not be used.
These properties mirror the return values of the
lng() and lat() accessor methods and
they allow a GLatLng to appear in places where a
GPoint is expected by a v1 client. This is
necessary where GLatLng appears in event details (i.e. in
arguments of event handler functions). In contrast to method
wrappers, it is impossible in the current infrastructure to
create event wrappers.
| Properties |
Type |
Description |
| x |
Number |
Deprecated. |
| y |
Number |
Deprecated. |
A GLatLngBounds instance represents a
rectangle in geographical coordinates, including one that crosses
the 180 degrees meridian.
Constructor
| Constructor |
Description |
| GLatLngBounds(sw?, ne?) |
Constructs a rectangle from the points at its south-west and
north-east corners. |
Methods
| Methods |
Return Value |
Description |
| equals(other) |
Boolean |
Returns true iff all parameters in this
rectangle are equal to the parameters of the other, within a
certain roundoff margin. |
| contains(latlng) |
Boolean |
Returns true iff the geographical coordinates
of the point lie within this rectangle. |
| intersects(other) |
Boolean |
What the name says. |
| containsBounds(other) |
Boolean |
What the name says. |
| extend(latlng) |
none |
Enlarges this rectangle such that it contains the given
point. In longitude direction, it is enlarged in the smaller of
the two possible ways. If both are equal, it is enlarged at the
eastern boundary. |
| getSouthWest() |
GLatLng |
Returns the point at the south-west corner of the
rectangle. |
| getNorthEast() |
GLatLng |
Returns the point at the north-east corner of the
rectangle. |
| toSpan() |
GLatLng |
Returns a GLatLng whose cordinates represent
the size of this rectangle. |
| isFullLat() |
Boolean |
Returns true if this rectangle extends from the
south pole to the north pole. |
| isFullLng() |
Boolean |
Returns true if this rectangle extends fully
around the earth in the longitude direction. |
| isEmpty() |
Boolean |
Returns true if this rectangle is empty. |
| getCenter() |
GLatLng |
Returns the point at the center of the rectangle. (Since 2.52) |
This interface is implemented by all controls. You
can implement it in order to provide a custom control for the
map. Controls are added to the map using the
GMap2.addControl() method.
In contrast to overlays, which are positioned
relative to the map, controls are positioned relative to the map
view, i.e. they don't move when the map moves.
Constructor
| Constructor |
Description |
| GControl(printable?, selectable?) |
Creates the prototype instance for a new control class. Flag
printable indicates that the control should be
visible in the print output of the map. Flag
selectable indicates that the control will contain
text that should be selectable. |
Methods
These methods will be called by the map when the
control is added to the map using
GMap2.addControl(). Thus, these methods will not be
called by you, but they will be implemented by
you.
| Methods |
Return Value |
Description |
| printable() |
Boolean |
Returns to the map if the control should be printable. |
| selectable() |
Boolean |
Returns to the map if the control contains selectable text. |
| initialize(map) |
Node |
Will be called by the map so the control can initialize
itself. The control will use the method
GMap2.getContainer() to get hold of the DOM element
that contains the map, and add itself to it. It returns the
added element. |
| getDefaultPosition() |
GControlPosition |
Returns to the map the position in the map view at which the
control appears by default. This will be overridden by the
second argument to GMap2.addControl(). |
This class described the position of a control in
the map view. It consists of a corner relative to where the control
is postioned, and an offset that determines this position. It can be
passed as optional argument position to the method
GMap2.addControl(), and it is returned from method
GControl.getDefaultPosition().
Constructor
| Constructor |
Description |
| GControlPosition(anchor, offset) |
Creates a specification for a control position. |
Constants
| Constants |
Description |
| G_ANCHOR_TOP_RIGHT |
The control will be anchored in the top right corner of the
map. |
| G_ANCHOR_TOP_LEFT |
The control will be anchored in the top left corner of the
map. |
| G_ANCHOR_BOTTOM_RIGHT |
The control will be anchored in the bottom right corner of the
map. |
| G_ANCHOR_BOTTOM_LEFT |
The control will be anchored in the bottom left corner of
the map. |
These implementations of interface
GControl are available.
Constructor
| Constructor |
Description |
| GSmallMapControl() |
Creates a control with buttons to pan in four directions,
and zoom in and zoom out. |
| GLargeMapControl() |
Creates a control with buttons to pan in four directions,
and zoom in and zoom out, and a zoom slider. |
| GSmallZoomControl() |
Creates a control with buttons to zoom in and zoom out. |
| GScaleControl() |
Creates a control that displays the map scale. |
| GMapTypeControl() |
Creates a control with buttons to switch between map types. |
Google provides some predefined map types - this class
is used to define custom ones. In order to show them on the
map, use the GMap2 constructor, or the
GMap2.addMapType() method. See also
GTileLayerOverlay to add to (rather than entirely replace)
the map's tile layers.
This class can also be subclassed. Constructor
arguments can be omitted if instantiated as a prototype. A subclass
constructor must invoke the GMapType constructor using
call().
Constructor
| Constructor |
Description |
| GMapType(layers, projection, name, opts?) |
Constructs a map type with the given tile layers,
projection, name, and optional parameters. |
Methods
These methods are mostly called by the map that
this maptype is passed to, but some methods may also be called from
outside the map, e.g. getBoundsZoomLevel().
| Methods |
Return Value |
Description |
| getSpanZoomLevel(center, span,
viewSize) |
Number |
Returns to the map the zoom level at which the map section
defined by center and span fits into the map view of the given
size in pixels. |
| getBoundsZoomLevel(bounds, viewSize) |
none |
Returns to the map the zoom level at which the map section
defined by bounds fits into the map view of the given size in
pixels. |
| getName(opt_short) |
String |
Returns to the map the name of the map type to be used as
the button label in the GMapTypeControl. |
| getProjection() |
GProjection |
Returns to the map the projection of this map type. |
| getTileSize() |
Number |
Returns to the map the map tile size in pixels of this map
type. The tiles are assumed to be quadratic. All tile layers
have the same tile size. |
| getTileLayers() |
Array of GTileLayer |
Returns to the map the array of tile layers. |
| getMinimumResolution(latlng?) |
Number |
Returns to the map the lowest zoom level at which this map
type is defined. |
| getMaximumResolution(latlng?) |
Number |
Returns to the map the highest zoom level at which this map
type is defined. |
| getTextColor() |
String |
Returns to the map the color that is best used for text that
is overlaid on the map. Used for the color of the text of the
copyright message displayed by the copyroght control. |
| getLinkColor() |
String |
Returns to the map the color that is best used for a
hyperlink that is overlaid on the map. Used for the color of the
link to the terms of use displayed by the copyroght
control. |
| getErrorMessage() |
String |
Returns to the map the error message that is displayed in
areas or on zoom level where this map type doesn't have map
tiles. |
| getCopyrights(bounds, zoom) |
Array of String |
Returns to the map the copyright messages appropriate
for the region described by bounds at the given
zoom level. This is used by the GCopyrightControl
to display the copyright message on the map. |
| getUrlArg() |
String |
Returns to the map a value that is used as a URL paramater
value to identify this map type in permalinks to the current map
view. This is currently only used by the maps application. |
Constants
| Constants |
Description |
| G_NORMAL_MAP |
This is the normal street map type. |
| G_SATELLITE_MAP |
This map type shows Google Earth satellite
images. |
| G_HYBRID_MAP |
This map type shows transparent street maps over Google
Earth satellite images. |
| G_DEFAULT_MAP_TYPES |
An array of all three predefined map types described
above. |
Events
| Events |
Arguments |
Description |
| newcopyright |
copyright |
This event is fired when a new copyright is added to the
copyright collection of one of the tile layers contained in this
map type. |
Instances of this class are used as the
opts? argument to the GMapType
constructor. There is no constructor for this class. Instead, this
class is instantiated as a javascript object literal.
Properties
| Properties |
Type |
Description |
| shortName |
String |
Sets the short name of the map type that is returned from
GMapType.getName(true). Default is the same as the
name. |
| urlArg |
String |
Sets the url argument of the map type that is returned from
GMapType.getUrlArg(). Default is the empty
string. |
| maxResolution |
Number |
Sets the maximum zoom level of this map type, returned by
GMapType.getMaximumResolution(). Default is the maximum
of all tile layers. |
| minResolution |
Number |
Sets the minimum zoom level of this map type, returned by
GMapType.getMinimumResolution(). Default is the minimum
of all tile layers. |
| tileSize |
Number |
Set the tile size returned by
GMapType.getTileSize(). Default is
256. |
| textColor |
String |
Sets the text color returned by
GMapType.getTextColor(). Default is
"black". |
| linkColor |
String |
Sets the text color returned by
GMapType.getLinkColor(). Default is
"#7777cc". |
| errorMessage |
String |
Sets the error message returned by
GMapType.getErrorMessage(). Default is the empty
string. |
GHierarchicalMapTypeControl provides a "nested" map type control
for selecting and switching between supported map types via buttons and nested
checkboxes. Controls will be made available for all map types currently attached
to the map at the time the control is constructed.
Map types added to the map appear as buttons as in the normal GMapTypeControl.
However, map types set as sub-types of other map types (see the addRelationship()
method below) will appear as checkbox sub-menu items below the parent button.
By default, maps support the set of G_DEFAULT_MAP_TYPES, though maps may also
add map types explicitly via GMap2.addMapType(). Controls will be made available
for all map types currently attached to the map at the time the control is
constructed. Note that because sub-types appear as checkboxes, you can toggle
their appearance with their parents or their siblings in the sub-menu.
Constructor
| Constructor |
Description |
| GHierarchicalMapTypeControl() |
Constructs the control. By default, the G_HYBRID_MAP
map type is made a child of the G_SATELLITE_MAP map type.
If this is not desired, the relationship can be removed by calling the
clearRelationships() method. |
Methods
| Methods |
Return Value |
Description |
addRelationship(
parentType,
childType,
childText?,
isDefault?) |
none |
Registers a parent/child relationship between map types with the
control. If childText is given, it will be displayed next
to the checkbox for the child map type instead of its name. If
isDefault is true, the child map type will be selected by
default. Note that all relationships must be set up before the control
is added. (Adding relationships after the control is added will have
no effect.) (Since 2.94) |
| removeRelationship(mapType) |
none |
Removes all relationships involving a map type from the control. (Since 2.94) |
| clearRelationships() |
none |
Removes all relationships from the control. (Since 2.94) |
You implement this interface in order to provide
custom map tile layers, either through GMapType or
GTileLayerOverlay. Your implementation of this interface should
use an instance of GTileLayer as a prototype, because
this implements the copyright handling for you.
Constructor
| Constructor |
Description |
| GTileLayer(copyrights, minResolution,
maxResolution) |
Constructor arguments can be omitted if instantiated as
a prototype. A Subclass constructor must invoke this constructor
using call(). |
Methods
These methods are called by the map and the map
type to which this tile layer is passed. You will need to
implement the methods marked abstract when you
implement a custom tile layer.
| Methods |
Return Value |
Description |
| minResolution() |
Number |
Returns to the map type the lowest zoom level of this tile
layer. |
| maxResolution() |
Number |
Returns to the map type the highest zoom level of this tile
layer. |
| getTileUrl(tile, zoom) |
String |
Abstract. Returns to the map the URL of the map
tile with the tile indices given by the x and
y properties of the GPoint, at the
given zoom level. |
| isPng() |
Boolean |
Abstract. Returns to the map whether the tiles are
in PNG image format and hence can be transparent. Otherwise GIF
is assumed. |
| getOpacity() |
Number |
Abstract. Returns to the map the opacity with which
to display this tile layer. 1.0 is opaque, 0.0 is
transparent. |
Events
| Events |
Arguments |
Description |
| newcopyright |
copyright |
This event is fired when a new copyright is added to the
copyright collection of this tile layer. |
A GTileLayerOverlay augments the map with a
GTileLayer. It implements the GOverlay interface
and thus is added to the map using the GMap2.addOverlay()
method. The GTileLayer is presented on top of the existing
map imagery - to replace the imagery instead, put the GTileLayer
inside a custom GMapType.
Constructor
| Constructor |
Description |
| GTileLayerOverlay(tileLayer) |
Creates a GOverlay that wraps the tileLayer. (Since 2.61) |
You use this class to manage copyright messages
displayed on maps of custom map type. If you don't implement custom
map types, then you don't need to use this class. A copyright
collection contains information about which copyright to display for
which region on the map at which zoom level. This is very important
for map types that display heterogenous data such as the satellite
map type.
Constructor
| Constructor |
Description |
| GCopyrightCollection(prefix?) |
Copyright messages produced from this copyright collection
will have the common prefix given as the argument.
Example: "Imagery (C) 2006" |
Methods
| Methods |
Return Value |
Description |
| () |
none |
|
| addCopyright(copyright) |
none |
Adds a copyright information object to the collection. |
| getCopyrights(bounds,
zoom) |
Array of String |
Returns all copyright strings that are pertinent
for the given map region at the given zoom level.
Example: [ "Google", "Keyhole" ] |
| getCopyrightNotice(bounds, zoom) |
String |
Returns the prefix and all relevant copyright strings
that are pertinent for the given map region at the given zoom level.
Example: "Imagery (C) 2006 Google, Keyhole" |
Events
| Events |
Arguments |
Description |
| newcopyright |
copyright |
This event is fired when a new copyright was added to this
copyright collection. |
A copyright object contains information about
which copyright message applies to a region of the map given by a
rectangle, at a given zoom level. You need this object only if you
implement custom map types or tile layers.
Constructor
| Constructor |
Description |
| GCopyright(id, bounds, minZoom, text) |
Creates a copyright information object with the given
properties. |
Properties
| Properties |
Type |
Description |
| id |
Number |
A unique identifier for this copyright information. |
| minZoom |
Number |
The lowest zoom level at which this information applies. |
| bounds |
GLatLngBounds |
The region to which this information applies. |
| text |
String |
The text of the copyright message. |
This is the interface for map projections. A map
projection instance is passed to the constructor of
GMapType. This interface is implemented by the
class GMercatorProjection, which is used by all
predefined map types. You can implement this interface if you want
to define map types with different map projections.
Methods
These methods are called by the map. You need to
implement them.
| Methods |
Return Value |
Description |
| fromLatLngToPixel(latlng, zoom) |
GPoint |
Returns the map coordinates in pixels for the point at the
given geographical coordinates, and the given zoom level. |
| fromPixelToLatLng(pixel, zoom,
unbounded?) |
none |
Returns the geographical coordinates for the point at the
given map coordinates in pixels, and the given zoom level. Flag
unbounded causes the geographical longitude coordinate
not to wrap when beyond the -180 or 180 degrees meridian. |
| tileCheckRange(tile, zoom,
tilesize) |
none |
Returns to the map if the tile index is in a valid range for
the map type. Otherwise the map will display an empty tile. It
also may modify the tile index to point to another
instance of the same tile in the case that the map contains more
than one copy of the earth, and hence the same tile at
different tile coordinates. |
| getWrapWidth(zoom) |
none |
Returns to the map the periodicity in x-direction, i.e. the
number of pixels after which the map repeats itself because it
wrapped once round the earth. By default, returns
Infinity, i.e. the map will not repeat itself. This
is used by the map to compute the placement of overlays on map
views that contain more than one copy of the earth (this usually
happens only at low zoom levels). (Since 2.46) |
This implementation of the
GProjection interface for the mercator projection is
used by all predefined map types.
Constructor
| Constructor |
Description |
| GMercatorProjection(zoomlevels) |
Creates a mercator projection for the given number of zoom
levels. |
Methods
| Methods |
Return Value |
Description |
| fromLatLngToPixel(latlng, zoom) |
GPoint |
See GProjection. |
| fromPixelToLatLng(pixel, zoom, unbounded?) |
GLatLng |
See GProjection. |
| checkTileRange(tile, zoom, tilesize) |
none |
See GProjection. |
| getWrapWidth(zoom) |
none |
See GProjection. Mercator projection is
periodic in longitude direction, therefore this returns the
width of the map of the entire Earth in pixels at the given zoom
level. (Since 2.46) |
This namespace contains functions that you use to
register event handlers, both for custom events and for DOM events,
and to fire custom events. All the events defined by this API are
custom events that are internally fired by
GEvent.triggerEvent().
Static Methods
| Static Methods |
Return Value |
Description |
| addListener(source, event, handler) |
GEventListener |
Registers an event handler for a custom event on the source
object. Returns a handle that can be used to eventually
deregister the handler. The event handler will be called with
this set to the source object. |
| addDomListener(source, event, handler) |
GEventListener |
Registers an event handler for a DOM event on the source
object. The source object must be a DOM Node. Returns a handle
that can be used to eventually deregister the handler. The event
handler will be called with this set to the source
object. This function uses the DOM methods for the current
browser to register the event handler. |
| removeListener(handle) |
none |
Removes a handler that was installed using
addListener() or addDomListener(). |
| clearListeners(source, event) |
none |
Removes all handlers on the given object for the given event
that were installed using addListener() or
addDomListener(). |
| clearInstanceListeners(source) |
none |
Removes all handlers on the given object for all events that
were installed using addListener() or
addDomListener(). |
| trigger(source, event, ...) |
none |
Fires a custom event on the source object. All arguments
after event are passed as arguments to the event
handler functions. |
| bind(source, event, object,
method) |
none |
Registers an invocation of the method on the given object as
the event handler for a custom event on the source
object. Returns a handle that can be used to eventually
deregister the handler. |
| bindDom(source, event, object,
method) |
none |
Registers an invocation of the method on the given object as
the event handler for a custom event on the source
object. Returns a handle that can be used to eventually
deregister the handler. |
| callback(object, method) |
none |
Returns a closure that calls method on
object. |
| callbackArgs(object, method, ...) |
none |
Returns a closure that calls method on
object with the given arguments. |
Events
| Events |
Arguments |
Description |
| clearlisteners |
event? |
This event is fired on object when
clearListeners() or
clearInstanceListeners() is called on that
object. Of course, the event is fired before the
functions are executed. |
This class is opaque. It has no methods and no
constructor. Its instances are returned from
GEvent.addListener() or
GEvent.addDomListener() and are eventually passed back
to GEvent.removeListener().
This namespace provides a factory method to create
XmlHttpRequest instances in a browser independent
way.
Static Methods
| Static Methods |
Return Value |
Description |
| create() |
GXmlHttp |
Factory to create a new instance of
XmlHttpRequest. |
This namespace provides static methods to handle
XML documents and document fragments.
Static Methods
| Static Methods |
Return Value |
Description |
| parse(xmltext) |
Node |
Parses the given string as XML text and returns a DOM
representation. If the browser doesn't support XML parsing
natively, this returns the DOM node of an empty DIV
element. |
| value(xmlnode) |
String |
Returns the text value (i.e., only the plain text content)
of the XML document fragment given in DOM representation. |
This class provides methods to apply XSLT to XML
in a browser-independent way.
Static Methods
| Static Methods |
Return Value |
Description |
| create(xsltnode) |
GXslt |
Creates a GXslt instance from the XSLT
stylesheet given as DOM representation. |
| transformToHtml(xmlnode, htmlnode) |
Boolean |
Uses the XSLT stylesheet given in the constructor of this
GXslt instance to transform the XML document given
as DOM representation in xmlnode. Appends the
resulting HTML document fragment to the given
htmlnode. This only works if the browser natively
supports XSL transformations, in which case it will return
true. Otherwise, this function will do nothing and
return false. |
This namespace contains some static methods that
help you to debug web applications. When you use one of the
write*() methods for the first time, a floating window
opens on the page and displays the written messages.
Static Methods
| Static Methods |
Return Value |
Description |
| write(message, color?) |
none |
Writes the message as plain text into the log window. HTML
markup characters will be escaped so that they are visible as
characters. |
| writeUrl(url) |
none |
Writes a link to the given URL into the log window. |
| writeHtml(html) |
none |
Writes text as HTML in the log window. |
This class makes a DOM element draggable. The static members
for changing the drag cursors affect all subsequently created draggable objects,
such as the map, zoom control slider, and overview map rectangles. The
per-instance members affect only their particular instance. For example,
before creating the map, you can call
GDraggableObject.setDraggableCursor('default') and
GDraggableObject.setDraggingCursor('move')
to get the pre-API 2.56 style. Alternatively, the Map constructor can take
options to set its DraggableObject's cursor style. See the
W3C CSS specification
for allowable cursor values.
Constructor
| Constructor |
Description |
| GDraggableObject(src, opts?) |
Sets up event handlers so that the source element can be dragged.
Left and top optionally position the element, and the optional container
serves as a bounding box.
(Since 2.59) |
Static Methods
| Static Methods |
Return Value |
Description |
| setDraggableCursor(cursor) |
none |