`
isiqi
  • 浏览: 16026274 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Google Maps API Reference——Google 地图 API 文档之七-2

阅读更多

class GMapOptions

This class represents optional arguments to the GMap2 constructor. It has no constructor, but is instantiated as an 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)

enum GMapPane

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

class GKeyboardHandler

Instantiate this class to add keyboard bindings to a map. The key bindings are the same as for the maps application.

Key(s) 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.

interface GOverlay

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.

class GInfoWindow

GInfoWindow has no constructor. It is created by the map and accessed by its method GMap2.getInfoWindow().

Methods

Methods Return Value Description
selectTab(index) none Selects the tab with the given index. This has the same effect as clicking on the corresponding tab.
hide() none Makes the info window invisible. NOTE: This doesn't close the info window. It can be made visible again using show().
show() none Makes the info window visible if its currently invisible.
isHidden() Boolean Returns true iff the info window is hidden. This includes the state that it's closed.
reset(point, tabs, size, offset?, selectedTab?) none Resets the state of the info window. Each argument may be null and then its value will not be changed from the current value.
getPoint() GLatLng Returns the geographical point at which the info window is anchored. The tip of the window points to this point on the map, modulo the pixel offset.
getPixelOffset() GSize Returns the offset, in pixels, of the tip of the info window from the point on the map at whose geographical coordinates the info window is anchored.
getSelectedTab() Number Returns the index, starting at 0, of the current selected tab.
getTabs() Array of GInfoWindowTabs Returns the array of tabs in this info window. (Since 2.59)
getContentContainers() Array of Node Returns the array of DOM nodes that hold the content of the tabs of this info window. (Since 2.59)

Events

Events Arguments Description
closeclick none This event is fired when the info window close button is clicked. An event handler for this event can implement to close the info window, by calling the GMap2.closeInfoWindow() method.

class GInfoWindowTab

An array of instances of this class can be passed as the tabs argument to the methods GMap2.openInfoWindowTabs(), GMap2.openInfoWindowTabsHtml(), GMarker.openInfoWindowTabs(), GMarker.openInfoWindowTabsHtml(), and the GMarker.bindInfoWindow*() variants. If the array contains more than one element, the info window will be shown with tabs. Every InfoWindowTab object contains two items: content defines the content of the info window when the tab is selected, and label defines the label of the tab. The properties are passed as arguments to the constructor. For the openInfoWindowTabs() methods, content is a DOM Node. For the methods openInfoWindowTabsHtml(), content is a string that contains HTML text.

Constructor

Constructor Description
GInfoWindowTab(label, content) Creates an info window tab data structure that can be passed in the tabs argument to openInfoWindowTabs*() methods.

class GInfoWindowOptions

Instances of this class are used in the opts? argument to the methods openInfoWindow(), openInfoWindowHtml(), openInfoWindowTabs(), openInfoWindowTabsHtml(), the bindInfoWindow*() variants, and showMapBlowup() of classes GMap2 and GMarker. There is no constructor for this class. Instead, this class is instantiated as javascript object literal.

Properties

As the name of this class indicates, all properties are optional.

Properties Type Description
selectedTab Number Selects the tab with the given index, starting at 0, instead of the first tab (with index 0).
maxWidth Number Maximum width of the info window content, in pixels.
noCloseOnClick Boolean Indicates whether or not the info window should close for a click on the map that was not on a marker. If set to true, the info window will not close when the map is clicked. The default value is false. (Since 2.83)
onOpenFn Function Function is called after the info window is opened and the content is displayed.
onCloseFn Function Function is called when the info window is closed.
zoomLevel Number Pertinent for showMapBlowup() only. The zoom level of the blowup map in the info window.
mapType GMapType Pertinent for showMapBlowup() only. The map type of the blowup map in the info window.

class GMarker

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 the passed point of either GPoint or GLatLng 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(latlng, opts?) Creates a marker at the latlng 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.
bindInfoWindow(content, opts?) none Binds the given DOM node to this marker. The content within this node will be automatically displayed in the info window when the marker is clicked. Pass content as null to unbind. (Since 2.85)
bindInfoWindowHtml(content, opts?) none Binds the given HTML to this marker. The HTML content will be automatically displayed in the info window when the marker is clicked. Pass content as null to unbind. (Since 2.85)
bindInfoWindowTabs(tabs, opts?) none Binds the given GInfoWindowTabs (provided as DOM nodes) to this marker. The content within these tabs' nodes will be automatically displayed in the info window when the marker is clicked. Pass tabs as null to unbind. (Since 2.85)
bindInfoWindowTabsHtml(tabs, opts?) none Binds the given GInfoWindowTabs (provided as strings of HTML) to this marker. The HTML content within these tabs will be automatically displayed in the info window when the marker is clicked. Pass tabs as null to unbind. (Since 2.85)
closeInfoWindow() none Closes the info window only if it belongs to this marker. (Since 2.85)
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.
getTitle() String Returns the title of this marker, as set by the constructor via the GMarkerOptions.title property. Returns undefined if no title is passed in. (Since 2.85)
getPoint() GLatLng Returns the geographical coordinates at which this marker is anchored, as set by the constructor or by setPoint(). (Deprecated since 2.88)
getLatLng() GLatLng Returns the geographical coordinates at which this marker is anchored, as set by the constructor or by setLatLng(). (Since 2.88)
setPoint(point) none Sets the geographical coordinates of the point at which this marker is anchored. (Deprecated since 2.88)
setLatLng(point) none Sets the geographical coordinates of the point at which this marker is anchored. (Since 2.88)
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.
setImage(url) none Requests the image specified by the url to be set as the foreground image for this marker. Note that neither the print image nor the shadow image are adjusted. Therefore this method is primarily intended to implement highlighting or dimming effects, rather than drastic changes in marker's appearances. (Since 2.75)
hide() none Hides the marker if it is currently visible. Note that this function triggers the event GMarker.visibilitychanged in case the marker is currently visible. (Since 2.77)
show() none Shows the marker if it is currently hidden. Note that this function triggers the event GMarker.visibilitychanged in case the marker is currently hidden. (Since 2.77)
isHidden() Boolean Returns true if the marker is currently hidden. Otherwise returns false. (Since 2.77)

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.
infowindowbeforeclose none This event is fired before the info window of the map that was opened through this marker is closed. (Since 2.83)
infowindowclose none This event is fired when the info window of the map that was opened through this marker is closed. This happens when either the info window was closed, or when it was opened on another marker, or on the map. The event infowindowbeforeclose is fired before this event.
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.
visibilitychanged isVisible This event is fired when the visibility of the marker is changed (i.e. the visibility is flipped from visible to hidden or vice-versa). isVisible refers to the state of the marker after the visibility change has happened. (Since 2.77)

class GMarkerOptions

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, bouncy and auto-pan enabled 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)
autoPan Boolean Auto-pan the map as you drag the marker near the edge. If the marker is draggable the default value for this option is true. (Since 2.87)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics