class GPolyline
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(latlngs, color?, weight?, opacity?, opts?) |
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) |
getLength() |
Number |
Returns the length (in meters) of the polyline along the surface of a spherical Earth. (Since 2.85) |
getBounds() |
GLatLngBounds |
Returns the bounds for this polyline. (Since 2.85) |
hide() |
none |
Hides the polyline if it is both currently visible and GPolyline.supportsHide() returns true . Note that this function triggers the event GPolyline.visibilitychanged in case the polyline is currently visible. (Since 2.87) |
isHidden() |
Boolean |
Returns true if the polyline is currently hidden. Otherwise returns false . (Since 2.87) |
show() |
none |
Shows the polyline if it is currently hidden. Note that this function triggers the event GPolyline.visibilitychanged in case the polyline is currently hidden. (Since 2.87) |
supportsHide() |
Boolean |
Returns true if GPolyline.hide() is supported in the current environment for GPolyline objects. Otherwise returns false . (Since 2.87) |
Events
Events Arguments Description
remove |
none |
This event is fired when the polyline is removed from the map, using GMap2.removeOverlay() or GMap2.clearOverlays() . |
visibilitychanged |
isVisible |
This event is fired when the visibility state of the polyline toggles from visible to hidden or vice versa. The isVisible argument reflects the state of the polyline after completion of this visibility state. (Since 2.87) |
click |
latlng |
This event is fired when the polyline is clicked. Note that this event also subsequently triggers a "click" event on the map, where the polyline is passed as the overlay argument within that event. (Since 2.88) |
class GPolylineOptions
Instances of this class are used in GPolyline
's constructor. 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
clickable |
Boolean |
Toggles whether or not the polyline is clickable. The default value for this option is true , i.e. if the option is not specified, the polyline will be clickable. (Since 2.91) |
geodesic |
Boolean |
Render each edge of the polyline as a geodesic (a segment of a "great circle"). A geodesic is the shortest path between two points along the surface of the Earth. (Since 2.84) |
class GPolygon
This is very similar to a GPolyline
, except that you can additionally specify a fill color and opacity.
Constructor
Constructor Description
GPolygon(points, strokeColor?, strokeWeight?, strokeOpacity?, fillColor?, fillOpacity?, opts?) |
Creates a polygon from an array of vertices. The colors are 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 opacities is given as a number between 0 and 1. The line will be antialiased and semitransparent. (Since 2.69) |
Factory Methods
Factory Methods Return Value Description
fromEncoded(polylines, fill?, color?, opacity?, outline?) |
GPolygon |
Creates a polygon (consisting of a number of polylines) from encoded strings of aggregated points and levels. polylines contains an associative array of constituent polylines, encoded in the same format as described in the GPolyline.fromEncoded documentation. fill specifies whether to fill in the polygon with a certain color . opacity and outline specifies whether to stroke the polygon with the polyline's color, weight and opacity. In case multiple values are specified in polylines, the first polyline's values are taken. (Since 2.78) |
Methods
Methods Return Value Description
getVertexCount() |
Number |
Returns the number of vertices in the polygon. (Since 2.69) |
getVertex(index) |
GLatLng |
Returns the vertex with the given index in the polygon. (Since 2.69) |
getArea() |
Number |
Returns the area (in square meters) of the polygon, assuming a spherical Earth. (Since 2.85) |
getBounds() |
GLatLngBounds |
Returns the bounds for this polygon. (Since 2.85) |
hide() |
none |
Hides the polygon if it is both currently visible and GPolygon.supportsHide returns true . Note that this function triggers the event GPolygon.visibilitychanged in case the polygon is currently visible. (Since 2.87) |
isHidden() |
Boolean |
Returns true if the polygon is currently hidden. Otherwise returns false . (Since 2.87) |
show() |
none |
Shows the polygon if it is currently hidden. Note that this function triggers the event GPolygon.visibilitychanged in case the polygon is currently hidden. (Since 2.87) |
supportsHide() |
Boolean |
Returns true if GPolygon.hide() is supported in the current environment for GPolygon objects. Otherwise returns false . (Since 2.87) |
Events
Events Arguments Description
remove |
none |
This event is fired when the polygon is removed from the map, using GMap2.removeOverlay() or GMap2.clearOverlays() . |
visibilitychanged |
isVisible |
This event is fired when the visibility state of the polygon toggles from visible to hidden or vice versa. The isVisible argument reflects the state of the polygon after completion of this visibility state. (Since 2.87) |
click |
latlng |
This event is fired when the polygon is clicked. Note that this event also subsequently triggers a "click" event on the map, where the polygon is passed as the overlay argument within that event. (Since 2.88>) |
class GPolygonOptions
Instances of this class are used in GPolygon
's constructor. 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
clickable |
Boolean |
Toggles whether or not the polygon is clickable. The default value for this option is true , i.e. if the option is not specified, the polygon will be clickable. (Since 2.91) |
class GGroundOverlay
This object creates a rectangular image overlay on the map, whose boundaries are defined by GLatLngBounds
.
Constructor
Constructor Description
GGroundOverlay(imageUrl, bounds) |
Creates a ground overlay from an image URL and its bounds. (Since 2.79) |
Methods
Methods Return Value Description
hide() |
none |
Hides the ground overlay if it is currently visible. Note that this function triggers the event GGroundOverlay.visibilitychanged in case the ground overlay is currently visible. (Since 2.87) |
isHidden() |
Boolean |
Returns true if the ground overlay is currently hidden. Otherwise returns false . (Since 2.87) |
show() |
none |
Shows the ground overlay if it is currently hidden. Note that this function triggers the event GGroundOverlay.visibilitychanged in case the ground overlay is currently hidden. (Since 2.87) |
supportsHide() |
Boolean |
Always returns true . (Since 2.87) |
Events
Events Arguments Description
visibilitychanged |
isVisible |
This event is fired when the visibility state of the ground overlay toggles from visible to hidden or vice versa. The isVisible argument reflects the state of the ground overlay after completion of this visibility state. (Since 2.77) |
class GIcon
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. |
maxHeight |
Integer |
Specifies the distance in pixels in which a marker will visually "rise" vertically when dragged. (Since 2.79) |
dragCrossImage |
String |
Specifies the cross image URL when an icon is dragged. (Since 2.79) |
dragCrossSize |
GSize |
Specifies the pixel size of the cross image when an icon is dragged. (Since 2.79) |
dragCrossAnchor |
GPoint |
Specifies the pixel coordinate offsets (relative to the iconAnchor) of the cross image when an icon is dragged. (Since 2.79) |
class GPoint
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. |
class GSize
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. |
class GBounds
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. |
mid() |
GPoint |
Returns the pixel coordinates of the center of the rectangular area. (Since 2.88) |
min() |
GPoint |
Returns the pixel coordinates of the upper left corner of the rectangular area. |
max() |
GPoint |
Returns the pixel coordinates of the lower right corner of the rectangular area. |
containsBounds(other) |
Boolean |
Returns true if the passed rectangular area is entirely contained in this rectangular area. |
containsPoint(point) |
Boolean |
Returns true if the rectangular area (inclusively) contains the pixel coordinates. (Since 2.88) |
extend(point) |
none |
Enlarges this box so that the point is also contained in this box. |
class GLatLng
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, otherwise 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%. See below. (Deprecated since 2.89) |
distanceFrom(other, radius?) |
Number |
Returns the distance, in meters, from this point to the given point. By default, this distance is calculated given the default equatorial earth radius of 6378137 meters. The earth is approximated as a sphere, hence the distance could be off as much as 0.3%, especially in the polar extremes. You may also pass an optional radius argument to calculate distances between GLatLng coordinates on spheres of a different radius than earth. (Since 2.89) |
toUrlValue() |
String |
This version of the method has been deprecated in favor of the revised version (shown below) which passes an optional precision parameter. (Deprecated since 2.78) |
toUrlValue(precision?) |
String |
Returns a string that represents this point in a format suitable for use as a URL parameter value, separated by a comma, without whitespace. By default, precision is returned to 6 digits, which corresponds to a resolution to 4 inches/ 11 centimeters. An optional precision parameter allows you to specify a lower precision to reduce server load. Note: prior to 2.78, this precision parameter was not available. (Since 2.78) |
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. |
class GLatLngBounds
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. (Deprecated since 2.88) |
containsLatLng(latlng) |
Boolean |
Returns true iff the geographical coordinates of the point lie within this rectangle. (Since 2.88) |
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) |
interface GControl
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() . |
class GControlPosition
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. |
enum GControlAnchor
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. |
class GControl
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. |
GOverviewMapControl() |
Creates a collapsible overview mini-map in the corner of the main map for reference location and navigation (through dragging). The GOverviewMapControl creates an overview map with a one-pixel black border. |
class GMapType
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(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() |
Number |
Returns to the map the lowest zoom level at which this map type is defined. |
getMaximumResolution() |
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 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. |
getAlt() |
String |
Returns to the map the alternative text of this map type. (Since 2.86) |
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. |
class GMapTypeOptions
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
分享到:
- 浏览: 4140456 次
- 性别:
- 来自: 济南
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 . |
eve
评论