Visualization: Geomap: Google Chart Tools / Interactive Charts (Aka Visualization API)
Visualization: Geomap: Google Chart Tools / Interactive Charts (Aka Visualization API)
Visualization: Geomap: Google Chart Tools / Interactive Charts (Aka Visualization API)
Page 1 of 10
Make web
development
faster with
these
Chrome
Extensions!
Visualization: Geomap
Overview
Examples
Loading
Data Format
Configuration Options
Methods
Events
Data Policy
Notes
Overview
A geomap is a map of a country, continent, or region map, with colors and values assigned to specific regions. Values are
displayed as a color scale, and you can specify optional hovertext for regions. The map is rendered in the browser using
an embedded Flash player. Note that the map is not scrollable or draggable, but can be configured to allow zooming.
By: Google
Examples
We have two examples here: one that uses the regions display style, and another that uses the markers display style.
Regions Example
The regions style fills entire regions (typically countries) with colors corresponding to the values that you assign. Specify
the regions style by assigning options['dataMode'] = 'regions' in your code.
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 2 of 10
<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geomap']});
google.setOnLoadCallback(drawMap);
function drawMap() {
var data = new google.visualization.DataTable();
data.addRows(6);
data.addColumn('string', 'Country');
data.addColumn('number', 'Popularity');
data.setValue(0, 0, 'Germany');
data.setValue(0, 1, 200);
data.setValue(1, 0, 'United States');
data.setValue(1, 1, 300);
data.setValue(2, 0, 'Brazil');
data.setValue(2, 1, 400);
data.setValue(3, 0, 'Canada');
data.setValue(3, 1, 500);
data.setValue(4, 0, 'France');
data.setValue(4, 1, 600);
data.setValue(5, 0, 'RU');
data.setValue(5, 1, 700);
<body>
<div id='map_canvas'></div>
</body>
</html>
Markers Example
The "markers" style displays a circle, sized and colored to indicate a value, over the regions that you specify.
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 3 of 10
<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geomap']});
google.setOnLoadCallback(drawMap);
function drawMap() {
var data = new google.visualization.DataTable();
data.addRows(6);
data.addColumn('string', 'City');
data.addColumn('number', 'Popularity');
data.setValue(0, 0, 'New York');
data.setValue(0, 1, 200);
data.setValue(1, 0, 'Boston');
data.setValue(1, 1, 300);
data.setValue(2, 0, 'Miami');
data.setValue(2, 1, 400);
data.setValue(3, 0, 'Chicago');
data.setValue(3, 1, 500);
data.setValue(4, 0, 'Los Angeles');
data.setValue(4, 1, 600);
data.setValue(5, 0, 'Houston');
data.setValue(5, 1, 700);
</script>
</head>
<body>
<div id='map_canvas'></div>
</body>
</html>
Get started quickly with an Interactive Code Sample you can edit and save.
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 4 of 10
Loading
The google.load package name is "geomap"
Data Format
Two address formats are supported, each of which supports a different number of columns, and different data types for
each column. All addresses in the table must use one or the other; you cannot mix types.
l Format 1: Latitude/Longitude locations. This format works only when the dataMode option is 'markers'. If this
format is used, you do not need to include the Google Map Javascript. The location is entered in two columns, plus
two optional columns:
1. [Number, Required] A latitude. Positive numbers are north, negative numbers are south.
2. [Number, Required] A longitude. Positive numbers are east, negative numbers are west.
3. [Number, Optional] A numeric value displayed when the user hovers over this region. If column 4 is used, this
column is required.
4. [String, Optional] Additional string text displayed when the user hovers over this region.
l Format 2: Address, country name, region name locations, or US metropolitan area codes. This format works
with the dataMode option set to either 'markers' or 'regions'. The location is entered in one column, plus two
optional columns:
1. [String, Required] A map location. The following formats are accepted:
n A specific address (for example, "1600 Pennsylvania Ave").
n A country name as a string (for example, "England"), or an uppercase ISO-3166 code or its English text
equivalent (for example, "GB" or "United Kingdom").
n An uppercase ISO-3166-2 region code name or its English text equivalent (for example, "US-NJ" or "New
Jersey"). Note: Regions can only be specified when the dataMode option is set to 'regions'.
n A metropolitan area code. These are three-digit metro codes used to designate various regions; US
codes only supported. Note that these are not the same as telephone area codes.
2. [Number, Optional] A numeric value displayed when the user hovers over this region. If column 3 is used, this
column is required.
3. [String, Optional] Additional string text displayed when the user hovers over this region.
Note: A map can display a maximum of 400 entries; if your DataTable or DataView holds more than 400 rows, only the
first 400 will be shown. The fastest modes are dataMode='regions' with locations specified as ISO codes, and
dataMode='markers' with lat/long enties. The slowest mode is dataMode='markers' with a string address.
Important: Your DataTable must include every optional column preceding any column that you want to use. So, for
example, if you want to specify a lat/long table, and only wanted to use columns 1, 2, and 4, your DataTable must still
define column 3 (though you don't need to add any values to it):
dataTable.setValue(0,0,47.00);
dataTable.setValue(0,1,-122.00);
dataTable.setValue(0,3,"Hello World!");
Configuration Options
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 5 of 10
region string 'world' The area to display on the map. (Surrounding areas will
be displayed as well.) Can be either a country code (in
uppercase ISO-3166 format), or a one of the following
strings:
dataMode string 'regions' How to display values on the map. Two values are
supported:
width string '556px' Width of the visualization. If no units are given, the
default unit is pixels.
height string '347px' Height of the visualization. If no units are given, the
default unit is pixels.
colors Array of RGB [0xE0FFD4, Color gradient to assign to values in the visualization.
numbers in 0xA5EF63, You must have at least two values; the gradient will
the format 0x50AA00, include all your values, plus calculated intermediary
0xRRGGBB 0x267114] values, with the lightest color as the smallest value,
and the darkest color as the highest.
showZoomOut boolean false If true, display a button with the label specified by the
zoomOutLabel property. Note that this button
does nothing when clicked, except throw the
zoomOut event. To handle zooming, catch this event
and change the region option. You can only specify
showZoomOut if the region option is smaller than
the world view. One way of enabling zoom in behavior
would be to listen for the regionClick event,
change the region property to the appropriate
region, and reload the map.
Methods
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 6 of 10
draw(data, None Draws the map. Can return before drawing is done (see
options) drawingDone() event).
Events
select Fired when the user clicks a region with an assigned value. None
To learn what has been selected, call getSelection().
Available only when the dataMode option is set to
'regions'.
regionClick Called when a region is clicked. Works both for 'regions' An object with a single
and 'markers' dataMode. However, in marker mode, this property, region, that is a
will not be thrown for the specific country assigned in the string in ISO-3166 format
'region' option (if a specific country was listed). describing the region clicked.
zoomOut Called when the zoom out button is clicked. To handle None
zooming, catch this event and change the region option.
Data Policy
Locations are geocoded by Google Maps. Please see the Google Maps Terms of Service for more information on their
data policy.
Notes
Because of Flash security settings, this (and all Flash-based visualizations) might not work correctly when accessed from
a file location in the browser (e.g., file:///c:/webhost/myhost/myviz.html) rather than from a web server URL (e.g.,
http://www.myhost.com/myviz.html). This is typically a testing issue only. You can overcome this issue as described on
the Macromedia web site.
©2010 Google - Code Home - Terms of Service - Privacy Policy - Site Directory
Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 7 of 10
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 8 of 10
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization A... Page 9 of 10
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010
Visualization: Geomap - Google Chart Tools / Interactive Charts (aka Visualization... Page 10 of 10
http://code.google.com/apis/visualization/documentation/gallery/geomap.html 07-07-2010