center
(required if markers not present) defines the center
of the map, equidistant from all edges of the map. This parameter takes a
location as either a comma-separated {latitude,longitude} pair (e.g.
"40.714728,-73.998672") or a string address (e.g. "city hall, new york, ny")
identifying a unique location on the face of the earth.
Latitudes and longitudes are defined using numerals within a comma-separated text string that have a precision to 6 decimal places. For example, "40.714728,-73.998672" is a valid geocode value. Precision beyond the 6 decimal places is ignored.
Latitude and longitude values must correspond to a valid location on the
face of the earth. Latitudes can take any value between -90
and
90
while longitude values can take any value between
-180
and 180
. If you specify an invalid latitude or
longitude value, your request will be rejected as a bad request.
Most people don't speak in latitudes and longitudes; they denote locations using addresses. The process of turning an address into a geographic point is known as geocoding and the Static Maps service can perform geocoding for you if you provide valid addresses.
In any parameter where you may provide a latitude/longitude, you may instead specify a string indicating an address. Google will geocode the address and provide the Static Map service with a latitude/longitude value to use in placing markers or specifying locations. The string should be URL-escaped, so addresses such as "City Hall, New York, NY" should be converted to "City+Hall,New+York,NY", for example.
Note that addresses may reflect either precise locations, such as street addresses, polylines such as named routes, or polygonal areas such as cities, countries, or national parks. For polylinear and polygonal results, the Static Map server will use the center point of the line/area as the address center. If you have doubt about how an address may geocode, you can test out the address using this Geocoding Utility.
zoom
(required if markers not present) defines the
zoom level of the map, which determines the
magnification level of the map. This parameter takes a numerical value
corresponding to the zoom level of the region desired.
Maps on Google Maps have an integer "zoom level" which defines the
resolution of the current view. Zoom levels between 0
(the lowest
zoom level, in which the entire world can be seen on one map) to
21+
(down to individual buildings) are possible within the
default roadmap maps view.
Google Maps sets zoom level 0
to encompass the entire earth.
Each succeeding zoom level doubles the precision in both horizontal and
vertical dimensions. More information on how this is done is available in the
Google Maps API documentation.
Note: not all zoom levels appear at all locations on the earth. Zoom levels vary depending on location, as data in some parts of the globe is more granular than in other locations.
If you send a request for a zoom level in which no map tiles exist, the Static Maps API will return a blank image instead.
size
(required) defines the rectangular dimensions of the map
image. This parameter takes a string of the form
valuexvalue
where horizontal pixels are denoted
first while vertical pixels are denoted second. For example,
500x400
defines a map 500 pixels wide by 400 pixels high. If you
create a static map that is 100 pixels wide or smaller, the "Powered by
Google" logo is automatically reduced in size.
Images may be returned in several common web graphics formats: GIF,
JPEG and PNG. The format
parameter takes one of the
following values:
png8
or png
(default) specifies the 8-bit
PNG
format.png32
specifies the 32-bit
PNG
format.gif
specifies the
GIF format.jpg
specifies the
JPEG compression
format.jpg-baseline
specifies a non-progressive
JPEG compression
format.jpg
and jpg-baseline
typically provide the
smallest image size, though they do so through "lossy" compression which may
degrade the image. gif
, png8
and png32
provide lossless compression.
Most JPEG images are progressive, meaning that they load a coarser image
earlier and refine the image resolution as more data arrives. This allows
images to be loaded quickly in webpages and is the most widespread use of JPEG
currently. However, some uses of JPEG (especially printing) require
non-progressive (baseline) images. In such cases, you may want to use the
jpg-baseline
format, which is non-progressive.
maptype
(optional) defines the type of map to construct.
There are several possible maptype values, including roadmap
,
satellite
, hybrid
, and terrain
.
roadmap
(default) specifies a standard roadmap image, as is
normally shown on the Google Maps website. If no maptype
value
is specified, the Static Maps API serves roadmap
tiles by
default.satellite
specifies a satellite image.terrain
specifies a physical relief map image, showing
terrain and vegetation.hybrid
specifies a hybrid of the satellite and roadmap
image, showing a transparent layer of major streets and place names on the
satellite image.language
(optional) defines the language to use for display
of labels on map tiles. Note that this parameter is only supported for some
country tiles; if the specific language requested is not supported for the
tile set, then the default language for that tileset will be used.
markers
(optional) define one or more markers to attach to
the image at specified locations. This parameter takes a single marker
definition with parameters separated by the pipe character (|
).
Multiple markers may be placed within the same markers
parameter
as long as they exhibit the same style; you may add additional markers of
differing styles by adding additional markers
parameters.
Note that if you supply markers for a map, you do not need to specify the
(normally required) center
and zoom
parameters.
The markers
parameter defines a set of one or more markers at
a set of locations. Each marker defined within a single markers
declaration must exhibit the same visual style; if you wish to display markers
with different styles, you will need to supply multiple markers
parameters with separate style information.
The markers
parameter takes set of value assignments
(marker descriptors) of the following format:
markers=markerStyles|markerLocation1|
markerLocation2|...
etc.
The set of markerStyles is declared at the beginning of the
markers
declaration and consists of zero or more style
descriptors separated by the pipe character (|
), followed
by a set of one or more locations also separated by the pipe character
(|
). (The pipe character is also %7C in ASCII if you are encoding
your URLs.)
Because both style information and location information is delimited via the pipe character, style information must appear first in any marker descriptor. Once the Static Map server encounters a location in the marker descriptor, all other marker parameters are assumed to be locations as well.
The set of marker style descriptors is a series of value assignments
separated by the pipe (|
) character. This style descriptor
defines the visual attributes to use when displaying the markers within this
marker descriptor. These style descriptors contain the following key/value
assignments:
size:
(optional) specifies the size of marker from
the set {tiny, mid, small}
. If no size
parameter
is set, the marker will appear in its default (normal) size.color:
(optional) specifies a 24-bit color
(example: color=0xFFFFCC
) or a predefined color from the set
{black, brown, green, purple, yellow, blue, gray, orange, red,
white}
.
Note that transparencies (specified using 32-bit hex color values) are not supported in markers, though they are supported for paths.
label:
(optional) specifies a single
uppercase alphanumeric character from the set {A-Z, 0-9}. (The
requirement for uppercase characters is new to this version of the API.)
Note that default and mid
sized markers are the only markers
capable of displaying an alphanumeric-character
parameter.
tiny
and small
markers are not capable of
displaying an alphanumeric-character.Note: instead of using these markers, you may wish to use your own custom icon.
Each marker descriptor must contain a set of one or more locations defining
where to place the marker on the map. These locations may be either specified
as latitude/longitude values or as addresses. These locations are separated using the
pipe character (|
).
The location parameters define the marker's location on the map. If the
location is off the map, that marker will not appear in the constructed image
provided that center
and zoom
parameters are
supplied. However, if these parameters are not supplied, the Static Map server
will automatically construct an image which contains the supplied markers.
(See Implicit Positioning below.)
A sample marker declaration is shown below. Note that we define one set of styles and three locations:
http://maps.google.com/maps/api/staticmap?center=Williamsburg,Brooklyn,NY&zoom=13&size=400x400& markers=color:blue|label:S|11211|11206|11222&sensor=true_or_false
To define markers with differing styles, we need to supply multiple
markers
parameters. This set of markers
parameters
defines three markers: one blue marker labeled "S" at 62.107733, -145.5419,
one tiny green marker at "Delta Junction, AK", and one mid-sized yellow marker
labeled "C" at "Tok, AK". These markers are shown in the example below:
http://maps.google.com/maps/api/staticmap?center=63.259591,-144.667969&zoom=6&size=400x400\ &markers=color:blue|label:S|62.107733,-145.541936&markers=size:tiny|color:green|Delta+Junction,AK\ &markers=size:mid|color:0xFFFF00|label:C|Tok,AK&sensor=false
Rather than use Google's marker icons, you are free to use your own custom
icons instead. Custom icons are specified using the following descriptors to
the markers
parameter:
icon
specifies a URL to use as the marker's custom icon.
Images may be in PNG, JPEG or GIF formats, though PNG is recommended.shadow
(default true
) indicates that the
Static Maps service should construct an appropriate shadow for the image.
This shadow is based on the image's visible region and its
opacity/transparency.The icon
parameter must be specified using a URL (which
should be
URL-encoded).
You may use any valid URL of your choosing, or a
URL-shortening service such as http://bit.ly
or
http://tinyurl.com
. Most URL-shortening services have the
advantage of automatically encoding URLs. Icons are limited to sizes of
4096 pixels (64x64 for square images), and the Static Maps service allows
up to five unique custom icons per request. Note that each of these unique
icons may be used multiple times within the static map.
Custom icons that have a shadow:true
descriptor (the default)
will have their "anchor point" set as the bottom center of the provided icon
image, from which the shadow is cast. Icons without a shadow (setting
a shadow:false
descriptor) are instead assumed to be icons
centered on their specified locations, so their anchor points are set as
the center of the image.
The following example uses Google's Chart API to create custom markers, showing several coffee shops in New York City:
http://maps.google.com/maps/api/staticmap?size=480x480&markers= icon:http://chart.apis.google.com/chart%3Fchst%3Dd_map_pin_icon%26chld%3Dcafe%257C996600| 224+West+20th+Street|75+9th+Ave|700+E+9th+St&sensor=true_or_false
Note: the Google Chart API, like the Google
Static Maps API, uses the pipe character ("|") to delimit parameters within
its URLs. Any icon
URLs containing such a character will cause
the Static Map service to interpret the pipe character as a parameter
delimiter before evaluating the URL. If you wish to use a URL containing
a pipe character, you can "double-encode" the pipe to %257C
,
which decodes to %7C
and will ensure that any pipe you place in
the icon's URL is not interpreted by the Static Map service. (We used this
trick above.)
The example below shows how such a URL will look after double-encoding the pipe character:
# Original URL: http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|996600 # Encoded URL: http://chart.apis.google.com/chart%3Fchst%3Dd_map_pin_icon%26chld%3Dcafe%7C996600 # Double-encoding of the "|" character: http://chart.apis.google.com/chart%3Fchst%3Dd_map_pin_icon%26chld%3Dcafe%257C996600
The path
parameter defines a set of one or more locations
connected by a path to overlay on the map image. The path
parameter takes set of value assignments (path descriptors) of the
following format:
path=pathStyles|pathLocation1|pathLocation2|...
etc.
Note that both path points are separated from each other using the pipe
character (|
). Because both style information and point
information is delimited via the pipe character, style information must appear
first in any path descriptor. Once the Static Map server encounters a
location in the path descriptor, all other path parameters are assumed to be
locations as well.
The set of path style descriptors is a series of value assignments
separated by the pipe (|
) character. This style descriptor
defines the visual attributes to use when displaying the path. These style
descriptors contain the following key/value assignments:
weight:
(optional) specifies the thickness of the
path in pixels. If no weight
parameter is set, the path will
appear in its default thickness (5 pixels).color:
(optional) specifies a color either as a
24-bit (example: color=0xFFFFCC
) or 32-bit hexadecimal value
(example: color=0xFFFFCCFF
), or from the set {black,
brown, green, purple, yellow, blue, gray, orange, red, white}
.
When a 32-bit hex value is specified, the last two characters
specify the 8-bit alpha transparency value. This value varies between
00
(completely transparent) and FF
(completely opaque). Note that transparencies are supported in paths, though
they are not supported for markers.
fillcolor:
(optional) indicates both that the path
marks off a polygonal area and specifies the fill color to use as an overlay
within that area. The set of locations following need not be a "closed"
loop; the Static Map server will automatically join the first and last
points. Note, however, that any stroke on the exterior of the filled area
will not be closed unless you specifically provide the same beginning
and end location.Some example path definitions appear below:
path=color:0x0000ff|weight:1
path=color:0xff0000ff|weight:5
path=color:0xffffffff|weight:10
These path styles are optional. If default attributes are desired, you may skip defining the path attributes; in that case, the path descriptor's first "argument" will consist instead of the first declared point (location).
In order to draw a path, the path
parameter must also be
passed two or more points. The Google Static Maps API will then connect the
path along those points, in the specified order. Each pathPoint is
denoted in the pathDescriptor separated by the |
(pipe)
character.
The following example defines a blue path with default 50% opacity from Union Square NY to Times Square, NY.
The specifics of the path
parameter appear below:
path=color:0x0000ff|weight:5|40.737102,-73.990318|40.749825,-73.987963|40.752946,-73.987384|40.755823,-73.986397
The following example defines the same path instead defining a solid red line with 100% opacity:
The specifics of this path
parameter appear below:
path=color:0xff0000ff|weight:5|40.737102,-73.990318|40.749825,-73.987963|40.752946,-73.987384|40.755823,-73.986397
The example below defines a polygonal area within Manhattan, passed a series of intersections as locations:
The specifics of this path
parameter appear below:
path=color:0x00000000|weight:5|fillcolor:0xFFFF0033|8th+Avenue+%26+34th+St,New+York,NY|\ 8th+Avenue+%26+42nd+St,New+York,NY|Park+Ave+%26+42nd+St,New+York,NY,NY|\ Park+Ave+%26+34th+St,New+York,NY,NY
Note that we set the path itself to be invisible and the polygonal area to have a 15% opacity.
Instead of a series of locations, you may instead declare a path as an
encoded polyline
by using the enc:
prefix within the location declaration of the
path
. Note that if you supply an encoded polyline path for a map,
you do not need to specify the (normally required) center
and
zoom
parameters.
The following example outlines the course of the Alaska Highway from Dawson Creek, BC to Delta Junction, AK with an encoded polyline:
http://maps.google.com/maps/api/staticmap?size=400x400&path=weight:3|color:orange|enc:polyline_data
As with standard paths, encoded polyline paths may also demarcate polygonal
areas if a fillcolor
argument is passed to the path
parameter.
The following example outlines a polygonal area for Brooklyn, NY:
http://maps.google.com/maps/api/staticmap?size=400x400&path=fillcolor:0xAA000033|color:0xFFFFFF00| enc:encoded_data
visible
(optional) specifies one or more
locations that should remain visible on the map,
though no markers or other indicators will be displayed. Use this parameter to
ensure that certain features or map locations are shown on the static
map.
Applications that determine the user's location via a sensor must pass
sensor=true
within your Static Maps API request URL. If your
application does not use a sensor, pass sensor=false
.
Since this tool does not determine location, it default to sensor=false
.
Try out the Google Static Maps API by building your own URL in the textbox above. Clicking on the parameters with a grey background and arrow will insert that parameter into the textbox for you. Clicking on any parameter or its short explanation will also display a full explanation in this box. Then click on the link above to view the Google Static Maps image!
Parameter descriptions are taken directly from Google's Static Maps API documentation with some editing for clarity
The textbox has some javascript cleverness in it that inserts new parameters before the sensor=false
parameter, keeping with Google's
convention of placing that parameter last. It will also reformat the parameters to one per line when a new one is inserted. Extraneous spaces will
either be converted to plus symbols or removed entirely from the link. However, it may be too clever for its own good. If it does something
annoying, please let me know.
This tool was built for beginners in a class offered at GIS Day 2010 in Redding, CA. For a easier, step-by-step wizard, see this sample from Google.