What are the Google Maps APIs?
The Google Maps APIs give
developers several ways of embedding Google Maps into web pages, and allows for
either simple use or extensive customization. There are now several API
offerings:
Depending on your needs,
you may find yourself using one or a combination of these APIs.
If
you operate an enterprise or commercial website, you may also be interested in Google
Maps API for Business.
Google Maps has a wide array of APIs that let you embed the
robust functionality and everyday usefulness of Google Maps into
your own website and applications, and overlay your own data on top of them.
What you can do with the Google Maps APIs
Maps JavaScript API Embed an
interactive Google Map in your webpage using JavaScript.
Google Earth API Take your visitors
anywhere on the Earth without leaving your web page.
Maps Image APIs Embed a Google Maps
image or Street View panorama in your web page without requiring JavaScript.
Static Maps - Street ViewWeb Services Use URL requests to access geocoding, directions, elevation, and place information.
Static Maps - Street ViewWeb Services Use URL requests to access geocoding, directions, elevation, and place information.
Maps for Business Google Maps API
for Business provides Enterprise-ready application support for your mapping
needs.
Places API Access information about
establishments, geographic locations, or prominent points of interest.
Maps applications on mobile devices
The Google Maps JavaScript API V3 has been developed
to cater to mobile devices, and is suitable for browser applications targeted
at both the desktop and devices that include a web browser with a full
JavaScript implementation, such as the Apple iPhone.
For applications targeted at devices not suitable for using the
JavaScript API, the Static Maps API delivers map images in GIF, JPG,
and PNG formats, including markers and polylines. Note that use of the Static
Maps API outside of browser based applications requires that the map image be
linked to Google Maps.
To incorporate maps in an Android application, use the Android Maps External Library.
To incorporate Maps in a native iPhone application, use the Apple iPhone Map Kit framework.
The Google Maps
JavaScript API supports the following web browsers:
Google
Maps JavaScript API V3:
·
IE
7.0+ (Windows) *
·
Firefox
3.0+ (Windows, Mac OS X, Linux)
·
Safari
4+ (Mac OS X, iOS)
·
Chrome
(Windows, Mac OS X, Linux)
·
Android
·
BlackBerry
6
·
Dolfin
2.0+ (Samsung Bada)
When using the JavaScript
Maps API, the following information is sent to Google:
- Map size and location for
retrieving map tiles and copyrights
- Addresses for geocoding
- Direction and Elevation requests
- Locations around which to search
for Places
- KML when using KmlLayer (V3) or
GGeoXml (V2)
The Google Maps APIs Can accessed
over SSL (HTTPS)
The
Google Maps JavaScript API V3, Google Static Maps API, and Google Maps API Web
Services can be accessed over secure (HTTPS) connections by developers using
either the free version of these APIs or Google
Maps API for Business. Please see the documentation for the API
concerned for information on how to access the API over SSL.
The
Google Maps JavaScript API V2 and Google Maps API for Flash can be accessed
over a secure (HTTPS) connection by Google
Maps API for Business customers only. If these Maps APIs are
used with a free Maps API key on a secure site, the browser may warn the user
about non-secure objects on the screen.
Google Maps JavaScript API v3
The
Google Maps Javascript API lets you embed Google Maps in your own web pages.
Version 3 of this API is especially designed to be faster and more applicable
to mobile devices, as well as traditional desktop browser applications.
The API provides a number of utilities for manipulating maps
(just like on the http://maps.google.com web page) and adding
content to the map through a variety of services, allowing you to create robust
maps applications on your website.
The JavaScript Maps API V3 is a free service, available for any
web site that is free to consumers. Please see the terms
of use for more information.
Basic Map Types
There
are many types of maps available within the Google Maps API. In addition to the
familiar "painted" road map tiles, the Google Maps API also supports
other maps types.
The
following map types are available in the Google Maps API:
·
MapTypeId.ROADMAP displays the
default road map view
·
MapTypeId.SATELLITE displays Google
Earth satellite images
·
MapTypeId.HYBRID displays a mixture
of normal and satellite views
·
MapTypeId.TERRAIN displays a physical
map based on terrain information.
You modify the map type in use by the Map by setting its mapTypeId property, either
within the constructor via setting its Map options object, or by
calling the map'ssetMapTypeId() method.
Layers Overview
Layers are
objects on the map that consist of one or more separate items, but are
manipulated as a single unit. Layers generally reflect collections of objects
that you add on top of the map to designate a common association. The Maps API
manages the presentation of objects within layers by rendering their
constituent items into one object (typically a tile overlay) and displaying
them as the map's viewport changes. Layers may also alter the presentation
layer of the map itself, slightly altering the base tiles in a fashion
consistent with the layer. Note that most layers, by design, may not be
accessed via their individual objects, but may only be manipulated as a unit.
To add a layer to a map, you only need to call setMap(), passing it the map
object on which to display the layer. Similarly, to hide a layer, call setMap(), passing null.
The
Maps API has several types of layers:
·
KmlLayer objects
render KML and GeoRSS elements into a Maps API V3 tile overlay.
·
HeatmapLayer objects
renders geographic data using a Heatmap visualization.
·
FusionTablesLayer objects
render data contained in Google Fusion
Tables.
·
The TrafficLayer object
renders a layer depicting traffic conditions and overlays representing traffic.
·
The TransitLayer object
displays the public transport network of your city on the map.
·
The WeatherLayer and CloudLayer objects allow you to add weather
forecasts and cloud imagery to your map.
·
The BicyclingLayer object
renders a layer of bike paths and/or bicycle-specific overlays into a common
layer. This layer is returned by default within theDirectionsRenderer when requesting
directions of travel mode BICYCLING.
·
The PanoramioLayer object
adds photos from Panoramio as a layer.
·
The DemographicsLayer object
renders United States demographic information as a layer, and is available to
Google Maps API for Business customers only. It is contained within the visualization library.
These layers are described below. The Demographics layer is
documented in the Demographics Layer chapter of the Google Maps API
for Business documentation.
Controls Overview
The maps displayed through the Google Maps API contain UI
elements to allow user interaction with the map. These elements are known as controls and you can include variations of these
controls in your Google Maps API application. Alternatively, you can do nothing
and let the Google Maps API handle all control behavior.
The
Maps API comes with a handful of built-in controls you can use in your maps:
·
The Zoom control displays a slider (for large
maps) or small "+/-" buttons (for small maps) to control the zoom
level of the map. This control appears by default in the top left corner of the
map on non-touch devices or in the bottom left corner on touch devices.
·
The Pan control displays buttons for panning the
map. This control appears by default in the top left corner of the map on
non-touch devices. The Pan control also allows you to rotate 45° imagery, if
available.
·
The Scale control displays a map scale element.
This control is not enabled by default.
·
The MapType control lets the user toggle between
map types (such as ROADMAP and SATELLITE). This control appears
by default in the top right corner of the map.
·
The Street View control contains a Pegman icon
which can be dragged onto the map to enable Street View. This control appears
by default in the top left corner of the map.
·
The Rotate control contains a small circular icon
which allows you to rotate maps containing oblique imagery. This control
appears by default in the top left corner of the map. (See 45° Imagery for more information.)
·
The Overview Map control displays a thumbnail
overview map reflecting the current map viewport within a wider area. This
control appears by default in the bottom right corner of the map, and is by
default shown in its collapsed state.
Note:
the previously existing Navigation control has been deprecated and divided into
separate Zoom and Pan controls.
You don't access or modify these map controls directly. Instead,
you modify the map's MapOptions fields
which affect the visibility and presentation of controls. You can adjust
control presentation upon instantiating your map (with appropriate MapOptions) or modify a map
dynamically by calling setOptions() to
change the map's options.
Services
Directions
Service
You can calculate directions (using a variety of methods of
transportation) by using the DirectionsService object. This object communicates with the Google Maps API
Directions Service which receives direction requests and returns computed
results. You may either handle these directions results yourself or use the DirectionsRendererobject to render these
results.
Directions may specify origins and destinations either as text
strings (e.g. "Chicago, IL" or "Darwin, NSW, Australia") or
as LatLng values. The
Directions service can return multi-part directions using a series of
waypoints. Directions are displayed as a polyline drawing the route on a map,
or additionally as a series of textual description within a
element (e.g. "Turn
right onto the Williamsburg Bridge ramp").
Distance
Matrix Service
Elevation
Service
Geocoding
Service
Maximum
Zoom Imagery Service
Street View
Service
Libraries
Distance
Matrix Service
Google's
Distance Matrix service computes travel distance and journey duration between
multiple origins and destinations using a given mode of travel.
This service does not return detailed route information. Route
information, including polylines and textual directions, can be obtained by
passing the desired single origin and destination to the Directions Service.
Elevation
Service
The
Elevation service provides elevation data for locations on the surface of the
earth, including depth locations on the ocean floor (which return negative
values). In those cases where Google does not possess exact elevation
measurements at the precise location you request, the service will interpolate
and return an averaged value using the four nearest locations.
The ElevationService object provides you
with a simple interface to query locations on the earth for elevation data.
Additionally, you may request sampled elevation data along paths, allowing you
to calculate the equidistant elevation changes along routes. The ElevationService object communicates
with the Google Maps API Elevation Service which receives elevation requests
and returns elevation data.
Note that these requests are rate-limited to discourage abuse of
the service. If instead you wish to calculate elevations for static, known
locations, see the Elevation Web Servicedocumentation.
With
the Elevation service, you can develop hiking and biking applications, mobile
positioning applications, or low resolution surveying applications.
Geocoding
Service
Geocoding
is the process of converting addresses (like "1600 Amphitheatre Parkway,
Mountain View, CA") into geographic coordinates (like latitude 37.423021
and longitude -122.083739), which you can use to place markers or position the
map.
The Google Maps API provides a geocoder class for geocoding addresses
dynamically from user input. These requests are rate-limited to discourage
abuse of the service. If instead, you wish to geocode static, known addresses,
see the Geocoding web service documentation.
Maximum
Zoom Imagery Service
The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap
imagery is available from zoom levels 0 to 18, for example. Satellite imagery
varies more widely as this imagery is not generated, but directly photographed.
Because satellite imagery is not always available at high zoom levels
for remote locations — sparsely populated areas or open ocean areas — you may
want to know the highest zoom level for imagery at a given location beforehand.
The MaxZoomService object provides a
simple interface for discovering the maximum zoom level at a given location for
which Google Maps has satellite imagery.
Street View
Service
Google Street View provides panoramic 360 degree views from
designated roads throughout its coverage area. Street View's API coverage is
the same as that for the Google Maps application (http://maps.google.com/). The list of currently
supported cities for Street View is available at the Google Maps Help Center.
The
Google Maps Javascript API provides a Street View service for obtaining and
manipulating the imagery used in Google Maps Street View. Unlike in the V2 API,
the Street View service in the Maps Javascript API V3 is supported natively
within the browser.
Libraries
The JavaScript code for the Maps API is loaded via a bootstrap URL of the form
http://maps.googleapis.com/maps/api/js
. This bootstrap request loads all of the main Javascript
objects and symbols for use in the Maps API. Some Maps API features are also
available in self-contained libraries which are not loaded unless you
specifically request them. Breaking up supplemental components into libraries
allows the main API to load (and parse) quickly; you only incur the additional
overhead of loading and parsing libraries if you need them.
You specify additional libraries to load within the bootstrap
request by specifying a
libraries
parameter, passing that
parameter the name of the library or libraries. Multiple libraries may be
specified as a comma-separated list. Once loaded, libraries are accessed via
the google.maps.
libraryName namespace.
The following libraries are currently
available:
·
adsense
allows your Maps API application to
include context-sensitive text ads, allowing you to share in ad revenue for ads
shown to your users. Consult the AdSense
library documentation for
more information.
·
drawing
provides a graphical interface for
users to draw polygons, rectangles, polylines, circles, and markers on the map.
Consult the Drawing
library documentation for
more information.
·
geometry
includes utility functions for
calculating scalar geometric values (such as distance and area) on the the
surface of the earth. Consult the Geometry
library documentation for
more information.
·
panoramio
contains functionality for adding Panoramio photo layers to your Maps API
application. Consult the Panoramio
Layers documentation for
more information.
·
places
enables your application to search
for Places such as establishments, geographic locations, or prominent points of
interest, within a defined area. Please read thePlaces
library documentation for
more information.
·
visualization
provides visual representations of
heatmap data, and demographic information for the United States. For more
information on heatmaps, see the Heatmap
Documentation. For more information on the Demographics Layer,
consult the Demographics
Layer documentation in
the Maps for Business guide.
·
weather
contains functionality for adding
weather forecasts and cloud imagery to your map. Consult the Weather
Layer documentation for
more information.