javascript - Google visualization geomap - Stack Overflow

I know from reading the assoc. Google group that there is not currently an event for clicking a specifi

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 badges
Add a ment  | 

1 Answer 1

Reset to default 8 +100

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742388439a4434531.html

相关推荐

  • javascript - Google visualization geomap - Stack Overflow

    I know from reading the assoc. Google group that there is not currently an event for clicking a specifi

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信