I know from reading the assoc. Google group that there is not currently an event for clicking a specific point when using the marker map (only regionClick
is implemented).
But was reading the docs and noticed the event Select
which says:
select Fired when the user clicks a visual entity. To learn what has been selected, call getSelection(). None
and
setSelection() none Selects the specified chart entities. Cancels any previous selection. Selectable entities are regions with an assigned value. A region correlates to a row in the data table (column index is null). For this chart, only one entity can be selected at a time. Extended description.
Would I be able to use this to get the entry that was clicked?
Example:
data.addRows([
['Rome', 2761477, 1285.31],
['Milan', 1324110, 181.76],
['Naples', 959574, 117.27],
['Turin', 907563, 130.17],
['Palermo', 655875, 158.9],
['Genoa', 607906, 243.60],
['Bologna', 380181, 140.7],
['Florence', 371282, 102.41]
]);
Somehow get that Milan was clicked? How would I do this? Or am I reading this wrong?
Google API for Geomaps: .html
Google Group stating there is no click event in Marker mode: /?fromgroups#!topic/google-visualization-api/K8uJoes8ZH0
I know from reading the assoc. Google group that there is not currently an event for clicking a specific point when using the marker map (only regionClick
is implemented).
But was reading the docs and noticed the event Select
which says:
select Fired when the user clicks a visual entity. To learn what has been selected, call getSelection(). None
and
setSelection() none Selects the specified chart entities. Cancels any previous selection. Selectable entities are regions with an assigned value. A region correlates to a row in the data table (column index is null). For this chart, only one entity can be selected at a time. Extended description.
Would I be able to use this to get the entry that was clicked?
Example:
data.addRows([
['Rome', 2761477, 1285.31],
['Milan', 1324110, 181.76],
['Naples', 959574, 117.27],
['Turin', 907563, 130.17],
['Palermo', 655875, 158.9],
['Genoa', 607906, 243.60],
['Bologna', 380181, 140.7],
['Florence', 371282, 102.41]
]);
Somehow get that Milan was clicked? How would I do this? Or am I reading this wrong?
Google API for Geomaps: http://code.google./apis/chart/interactive/docs/gallery/geochart.html
Google Group stating there is no click event in Marker mode: https://groups.google./forum/?fromgroups#!topic/google-visualization-api/K8uJoes8ZH0
Share Improve this question edited Feb 15, 2021 at 9:42 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Mar 21, 2012 at 11:20 ereere 1,7793 gold badges19 silver badges41 bronze badges1 Answer
Reset to default 8 +100You need call getSelection function when the select event is called. This function returns an array of objects. Each object have row and column attributes (if any). Use the row and the first column (0) to retrieve the label name (Rome, Milan, ...).
Example (http://jsfiddle/VtZQh/):
google.visualization.events.addListener(chart, 'select', function() {
var selection = chart.getSelection()[0];
var label = data.getValue(selection.row, 0);
alert(label);
});
Please refer to documentation to know more about getSelection
.