|
|
Google Maps API
Sign up for an API key API Documentation API Terms of Use API Blog API Discussion Group
|
IntroductionAudienceThis documentation is designed for people familiar with JavaScript programming and object-oriented programming concepts. You should also be familiar with Google Maps from a user's point of view. The "Hello, World" of Google MapsThe easiest way to start learning about this API is to see a simple example. The following web page displays a 300x300 map centered on Palo Alto:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API Example: simple</title>
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAEfCuQGsNiSWxRgf_vfNWaRQjskl1-YgiA_BGX2yRrf7htVrbmBTEB0IH-F489GrwP8-dHLib7cKKIQ"
type="text/javascript">
</script>
<script type="text/javascript">
//<![CDATA[
function onLoad() {
// The basics.
//
// Creates a map and centers it on Palo Alto.
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
}
}
//]]>
</script>
</head>
<body onload="onLoad()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
</html>
You can download this example to edit and play around with it, but you'll have to replace the key in that file with your own Maps API key. (If you register a key for a particular directory, it works for all subdirectories as well.) The URL in the example above ( <script src="http://maps.google.com/maps?file=api&v=1&key=abcdefg" type="text/javascript"> </script> The main class exported by the Google Maps API is The methods for manipulating and adding overlays to map instances are detailed below. Browser CompatibilityThe Google Maps API supports the same browsers as the Google Local site. See the list of supported browsers on Google Local. Since different applications require different behaviors for users with incompatible browsers, the Maps API provides a global method ( None of the examples in this document check for compatibility (other than the first example, above), nor do they display an error message for older browsers. Clearly real applications should do something more friendly with incompatible browsers, but we have omitted such checks to make the examples more readable. Note that certain browsers may have particular quirks regarding JavaScript. For example, IE doesn't allow JavaScript inside tables. XHTML and VMLWe recommend that you use standards-compliant XHTML on pages that contain maps. When browsers see the XHTML If you want to show polylines on your map (like the lines used by Google Maps to show driving directions), you need to include the VML namespace and some CSS code in your XHTML document, to make everything work properly in IE. Your XHTML document should begin like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Your Page Title Here</title>
<style type="text/css">
v\:* {
behavior:url(#default#VML);
}
</style>
<script src="http://maps.google.com/maps?file=api&v=1&key=abcdefg"
type="text/javascript">
</script>
</head>
See Microsoft's VML workshop for more information. API UpdatesThe After a new version is released, we will try to run the old and new versions concurrently for about a month. After a month, the old version will be turned off, and code that uses the old version will no longer work. The Maps team will transparently update the API with the most recent bug fixes and performance enhancements. These bug fixes should only improve performance and fix bugs, but we may inadvertently break some API clients. Please use the Maps API discussion group to report such issues. Geocoding, Routing, etc.The Google Maps API does not include geocoding or routing services at this time; in particular, you can't specify a location using its street address. However, there are a number of free geocoders on the web; if you need the latitude and longitude of a particular address, you can use one of those. ExamplesEach of the following examples shows only the relevant JavaScript code, not the full HTML file. You can plug the JS code into the skeleton HTML file shown earlier, or you can download the full HTML file for each example by clicking the link after the example. The BasicsThe following example (the same as the code from the example shown earlier) creates a map and centers it on Palo Alto. Note that you can drag the map around just as you can drag maps on the Google Maps site. var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
Map Movement and AnimationThe The following example displays a map, then waits two seconds, then pans to a new center.
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
window.setTimeout(function() {
map.recenterOrPanToLatLng(new GPoint(-122.1569, 37.4569));
}, 2000);
Adding Controls to the MapYou can add controls to the map with the
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
Event ListenersTo register an event listener, call the Note that this example relies on the presence of a
var map = new GMap(document.getElementById("map"));
GEvent.addListener(map, 'moveend', function() {
var center = map.getCenterLatLng();
var latLngStr = '(' + center.y + ', ' + center.x + ')';
document.getElementById("message").innerHTML = latLngStr;
});
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
Opening an Info WindowTo create an info window, call the You would typically place an info window above a marker, but you can place an info window anywhere on the map.
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
map.openInfoWindow(map.getCenterLatLng(),
document.createTextNode("Hello, world"));
View example (infowindow.html) Map OverlaysTo add a marker to a map, first create a GPoint; then give that point as the location of a new GMarker; then pass the marker to To add a polyline to a map, first create an array of points; then use those points to create a new GPolyline; then pass the polyline to The following example code creates ten random markers and a random polyline, to illustrate the use of map overlays. Remember to add the VML namespace and the necessary CSS code; see XHTML and VML for more information. // Center the map on Palo Alto.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
// Add 10 random markers in the map viewport using the default icon.
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for (var i = 0; i < 10; i++) {
var point = new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random());
var marker = new GMarker(point);
map.addOverlay(marker);
}
// Add a polyline with 4 random points. Sort the points by
// longitude so that the line does not intersect itself.
var points = [];
for (var i = 0; i < 5; i++) {
points.push(new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random()));
}
points.sort(function(p1, p2) { return p1.x - p2.x; });
map.addOverlay(new GPolyline(points));
Click HandlingTo handle clicks, call In the following code example, when the visitor clicks anywhere in the map, we create a new marker at that point. When the visitor clicks a marker, we remove it from the map.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
GEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
map.removeOverlay(overlay);
} else if (point) {
map.addOverlay(new GMarker(point));
}
});
Display Info Window Above MarkersIn the following example, we show a custom info window above each marker by listening to the click event for each marker. We take advantage of function closures to customize the info window content for each marker.
// Center the map on Palo Alto.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
// Create a marker whose info window displays the given number.
function createMarker(point, number) {
var marker = new GMarker(point);
// Show this marker's index in the info window when it is clicked.
var html = "Marker #<b>" + number + "</b>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
// Add 10 random markers in the map viewport using the default icon.
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for (var i = 0; i < 10; i++) {
var point = new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random());
var marker = createMarker(point, i + 1);
map.addOverlay(marker);
}
View example (markerinfowindow.html) Creating IconsThe following example creates a new type of marker, using the Google Ride Finder "mini" markers as an example. We have to specify the foreground image, the shadow image, and the points at which we anchor the icon to the map and anchor the info window to the icon.
// Create our "tiny" marker icon
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
// Center the map on Palo Alto.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
// Create one of our tiny markers at the given point.
function createMarker(point) {
var marker = new GMarker(point, icon);
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml("You clicked me!");
});
return marker;
}
// Add 10 random markers in the map viewport.
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for (var i = 0; i < 10; i++) {
var point = new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random());
var marker = createMarker(point);
map.addOverlay(marker);
}
Using Icon ClassesIn many cases, your icons may have different foregrounds, but the same shape and shadow. The easiest way to achieve this behavior is to use the copy constructor for the Note: this example isn't very localizable or scalable; it relies on the existence of a series of letter images corresponding to letters in the Latin-1 codeset.
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);
// Center the map on Palo Alto.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
// Create a marker whose info window displays the letter corresponding
// to the given index.
function createMarker(point, index) {
// Create a lettered icon for this point using our icon class from above
var letter = String.fromCharCode("A".charCodeAt(0) + index);
var icon = new GIcon(baseIcon);
icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
var marker = new GMarker(point, icon);
// Show this marker's index in the info window when it is clicked.
var html = "Marker <b>" + letter + "</b>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
// Add 10 random markers in the map viewport.
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for (var i = 0; i < 10; i++) {
var point = new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random());
var marker = createMarker(point, i);
map.addOverlay(marker);
}
Using XML and Asynchronous RPC ("AJAX") with MapsIn the following example, we download a static file ("data.xml") that contains a list of latitude and longitude coordinates in XML. When the download completes, we parse the XML and create a marker at each of the specified locations. Note: If the XML file includes HTML code, be sure to encode the HTML appropriately in the XML file. For example, change all occurrences of "<" in the HTML tags in the XML file to "<", then convert them back in your JavaScript code after dlownloading the XML file. (The XML file used by the following example doesn't include any HTML, so it doesn't need any encoding or decoding.)
// Center the map on Palo Alto.
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
// Download the data in data.xml and load it on the map. The format we
// expect is:
// <markers>
// <marker lat="37.441" lng="-122.141"/>
// <marker lat="37.322" lng="-121.213"/>
// </markers>
var request = GXmlHttp.create();
request.open('GET', 'data.xml', true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GPoint(parseFloat(markers[i].getAttribute("lng")),
parseFloat(markers[i].getAttribute("lat")));
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
}
request.send(null);
View example (async.html). Requires external XML data file named data.xml (or you can create your own). TroubleshootingIf your code doesn't seem to be working, here are some approaches that might help you track down the problem:
Other resourcesHere are some additional resources. Note that these sites are not owned or supported by Google. API OverviewThe
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Constructor | Description |
|---|---|
GMap(container, mapTypes?, width?, height?) |
Creates a new map inside of the given HTML container, which is typically a div element. We use the default set of map types ([G_MAP_TYPE, G_HYBRID_TYPE, G_SATELLITE_TYPE]) unless a different set is specified. Likewise, we use the size of the container to determine the map width and height unless a width and height are explicitly specified. |
| Method | Description |
|---|---|
enableDragging() |
Enables dynamic dragging (enabled by default). |
disableDragging() |
Disables dynamic dragging. |
draggingEnabled() |
Returns true if dynamic dragging is enabled. |
enableInfoWindow() |
Enables the info window on this map (enabled by default). |
disableInfoWindow() |
Disables the info window on this map. |
infoWindowEnabled() |
Returns true if the info window is enabled on this map. |
addControl(control) |
Adds the given map control to this map. |
removeControl(control) |
Removes the given map control from this map. |
| Method | Description |
|---|---|
getCenterLatLng() |
Returns the center point of the map viewport in latitude/longitude coordinates. |
getBoundsLatLng() |
Returns the latitude/longitude bounds of the map viewport. |
getSpanLatLng() |
Returns the width and height of the map viewport in latitude/longitude ticks. |
getZoomLevel() |
Returns the integer zoom level of the map. |
centerAtLatLng(latLng) |
Centers the map at the given point. |
recenterOrPanToLatLng(latLng) |
Centers the map at the given point, doing a fluid pan to the point if it is within the current map viewport. |
zoomTo(zoomLevel) |
Zooms to the given integer zoom level, ignoring the request if the given zoom level is outside the bounds of the current map type. |
centerAndZoom(latLng, zoomLevel) |
Atomically centers and zooms the map. Useful to initialize the map with an initial center and zoom level, as in the examples above. |
getMapTypes() |
Returns an array of map types supported by this map (currently G_MAP_TYPE, G_HYBRID_TYPE, and G_SATELLITE_TYPE). |
getCurrentMapType() |
Returns the map type currently in use (G_MAP_TYPE, G_HYBRID_TYPE, or G_SATELLITE_TYPE). |
setMapType(mapType) |
Switches this map to the given map type (G_MAP_TYPE, G_HYBRID_TYPE, or G_SATELLITE_TYPE). |
| Method | Description |
|---|---|
addOverlay(overlay) |
Adds the given overlay object (GMarker or GPolyline) to the map. |
removeOverlay(overlay) |
Removes the given overlay object from the map. |
clearOverlays() |
Removes all of the overlays from the map. |
| Method | Description |
|---|---|
openInfoWindow(latLng, htmlElem, pixelOffset?, onOpenFn?, onCloseFn?) |
Displays the info window with the given HTML content at the given point. htmlElem should be an HTML DOM element. If pixelOffset (GSize) is given, we offset the info window by that number of pixels, which lets users place info windows above markers and other overlays. If onOpenFn is given, we call that function when the window is displayed. If onCloseFn is given, we call that function when the window is closed. |
openInfoWindowHtml(marker, htmlStr, pixelOffset?, onOpenFn?, onCloseFn?) |
Like openInfoWindow, but takes an HTML string rather than an HTML DOM element. |
openInfoWindowXslt(marker, xmlElem, xsltUri, pixelOffset?, onOpenFn?, onCloseFn?) |
Like openInfoWindow, but takes an XML element and the URI of an XSLT document to produce the content of the info window. The first time a URI is given, the file at that URI is downloaded with GXmlHttp and subsequently cached. |
showMapBlowup(point, zoomLevel?, mapType?, pixelOffset?, onOpenFn?, onCloseFn?)) |
Shows a blowup of the map at the given GPoint. If the zoomLevel and mapType parameters are not given, we default to a zoom level of 1 and the current map type. |
closeInfoWindow() |
Closes the info window if it is open. |
| Event | Arguments | Description |
|---|---|---|
click |
overlay, point |
Triggered when the user clicks the map or an overlay on the map. If the click was on an overlay, we pass the overlay as an argument to the event handler. Otherwise, we pass the latitude/longitude point that was clicked on the map. |
move |
none | Triggered when the map is moving. This event is triggered continuously as the map is dragged. |
movestart |
none | Triggered at the beginning of a continuous pan/drag movement. This event is not triggered when the map moves discretely. |
moveend |
none | Triggered at the end of a discrete or continuous map movement. This event is triggered once at the end of a continuous pan. |
zoom |
oldZoomLevel, newZoomLevel |
Triggered after the map zoom level changes. |
maptypechanged |
none | Triggered after the map type (Map, Hybrid, or Satellite) changes. |
infowindowopen |
none | Triggered after the info window is displayed. |
infowindowclose |
none | Triggered after the info window is closed. |
addoverlay |
overlay |
Triggered after an overlay is added to the map. |
removeoverlay |
overlay |
Triggered after an overlay is removed from the map. Not triggered if clearOverlays is called—see the clearoverlays event below. |
clearoverlays |
none | Triggered after all overlays are cleared from the map. |
GMarkerGMarker is a type of map overlay that shows an icon at a single point on the map. The constructor takes an instance of GIcon, which can be shared among many markers, and the point at which it should be displayed. GMarker also includes some convenience methods to open info windows over the marker, which is common for Google Maps hacks.
| Constructor | Description |
|---|---|
GMarker(point, icon?) |
Creates a marker with the given icon at the given point. If no icon is given, we use the default Google Maps icon. |
| Method | Description |
|---|---|
openInfoWindow(htmlElem) |
Opens an info window with the given HTML content over this marker. htmlElem should be an HTML DOM element. |
openInfoWindowHtml(htmlStr) |
Like openInfoWindow, but takes an HTML string rather than an HTML DOM element. |
openInfoWindowXslt(xmlElem, xsltUri) |
Like openInfoWindow, but takes an XML element and the URI of an XSLT document to produce the content of the info window. The first time a URI is given, the file at that URI is downloaded with GXmlHttp and subsequently cached. |
showMapBlowup(zoomLevel?, mapType?) |
Shows a blowup of the map over this marker. We use a default zoom level of 1 and the current map type if the zoomLevel and mapType parameters are not given. |
| Event | Arguments | Description |
|---|---|---|
click |
none | Triggered when the user clicks on this marker. |
infowindowopen |
none | Triggered when the info window is opened above this marker with one of the methods above. |
infowindowclose |
none | Triggered when the info window above this marker is closed. |
GPolylineA polyline represents a vector polyline overlay on the map. A polyline is drawn with the vector drawing facilities of the browser if they are available or an image overlay from Google servers otherwise.
| Constructor | Description |
|---|---|
GPolyline(points, color?, weight?, opacity?) |
Constructs a polyline from the given array of latitude/longitude points. color is a hex HTML color (such as "#0000ff"), weight is an integer representing the width of the line in pixels, and opacity is a float between 0 and 1. |
GIconAn icon specifies the images used to display a marker on the map. For browser compatibility reasons, specifying an icon is actually quite complex. See the discussion above for more information. Note that you can use the default Maps icon if you don't want to specify your own.
Before you can display an icon, you must specify (at a minimum) the image, shadowImage, iconSize, shadowSize, and iconAnchor properties. If you use an info window, you must also specify the infoWindowAnchor property of the icon.
| Constructor | Description |
|---|---|
GIcon(copy?) |
Creates a new icon, copying the properties of the given icon if given. |
| Property | Description |
|---|---|
image |
The foreground image URL of the icon. |
shadow |
The shadow image URL of the icon. |
iconSize |
The pixel size of the foreground image of the icon. |
shadowSize |
The pixel size of the shadow image. |
iconAnchor |
The pixel coordinate relative to the top left corner of the icon image at which we should anchor this icon to the map. |
infoWindowAnchor |
The pixel coordinate relative to the top left corner of the icon image at which we should anchor the info window to this icon. |
printImage |
The URL of the foreground icon image we should use for printed maps. It should be the same size as the main icon image. |
mozPrintImage |
The URL of the foreground icon image we should use for printed maps in Firefox/Mozilla. It should be the same size as the main icon image. |
printShadow |
The URL of the shadow image we should use for printed maps. It should be a GIF image since most browsers cannot print PNG images. |
transparent |
The URL of a virtually transparent version of the foreground icon image used to capture IE click events. 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 |
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 non-IE browsers. |
GEventAll event registration and triggering is handled by the GEvent class. All methods in the GEvent class are static methods; you should call them using the form GEvent.bind(...) rather than (new Event()).bind(...).
| Method | Description |
|---|---|
addListener(source, eventName, listenerFn) |
Calls the given listenerFn function when the given event is triggered on the given source instance. We return an opaque listener token that can be used with removeListener. |
removeListener(listener) |
Removes the given listener, which should be a listener token returned by addListener. |
clearListeners(source, eventName) |
Removes all listeners for the given event on the given source. |
trigger(source, eventName, args...) |
Triggers the given event on the given source with the given list of arguments. |
bind(source, eventName, object, method) |
Binds the given method of the given object to the given source event. When the given event is triggered, the given method is called with object as the this. For example: GEvent.bind(map, 'move', this, this.onMapMove). |
GXmlHttpThe GXmlHttp class exports a factory method to create cross-browser-compatible XmlHttpRequest instances.
| Method | Description |
|---|---|
create() |
Factory method to construct a new XmlHttpRequest instance. |
GXmlThe GXml class provides a static method to parse a string of XML. The parser should work in any browser, though it falls back on a JavaScript XML parser by default if there is no native parser in the web browser. That default JavaScript XML parser may be quite slow, depending on the browser's JavaScript implementation.
| Method | Description |
|---|---|
parse(xmlStr) |
Parses the given string of XML, returning the XML DOM. |
value(xmlNode) |
Returns the textual content in the given XML element or node. Useful to pull out the text nodes from inside of an XML element. |
GXsltThe GXslt class provides factory methods to apply XSLT to XML in a brower-independent way. The class should work on any browser, though it falls back on a JavaScript XSLT implementation by default if there is no native XSLT processor in the web browser. That default JavaScript XSLT processor may be quite slow, depending on the browser's JavaScript implementation.
| Method | Description |
|---|---|
create(xsltXmlDoc) |
Returns a GXslt instance from the given XML DOM, which should be an XSLT document. |
| Method | Description |
|---|---|
transformToHtml(xmlDoc, htmlContainer) |
Transforms the given XML document using this XSLT, placing the resulting HTML in the given HTML DOM element container. |
GPointA GPoint represents a single, 2-dimensional coordinate. If a GPoint represents a latitude/longitude, then x is the longitude and y is the latitude, in decimal notation.
| Constructor | Description |
|---|---|
GPoint(x, y) |
Creates a new point with the given coordinate values. |
| Property | Description |
|---|---|
x |
The x (or horizontal) coordinate of the point. |
y |
The y (or vertical) coordinate of the point. |
GSizeGSize represents a 2-dimensional size measurement. If a GSize represents a latitude/longitude span, width is the number of longitude degrees, and height is the number of latitude degrees.
| Constructor | Description |
|---|---|
GSize(width, height) |
Creates a new size with the given measurement values. |
| Property | Description |
|---|---|
width |
The width measurement. |
height |
The height measurement. |
GBoundsGBounds represents a 2-dimensional bounding box. If the GBounds is in the latitude/longitude coordinate system, the x coordinates represent longitude and the y coordinates represent latitude. If the latitude/longitude bounds crosses the International Date Line, the "minimum" coordinates refer to the top left coordinates rather than the mathematical minimum of the two coordinates.
| Constructor | Description |
|---|---|
GBounds(minX, minY, maxX, maxY) |
Creates a new bounds with the given coordinates. |
| Property | Description |
|---|---|
minX |
The x coordinate of the top left corner of the bounds. |
minY |
The y coordinate of the top left corner of the bounds. |
maxX |
The x coordinate of the bottom right corner of the bounds. |
maxY |
The y coordinate of the bottom right corner of the bounds. |