Google geo store

I know that I read the message. google group that there is currently no event for clicking on a specific point when using a marker map (only regionClick is implemented)

But I read the documents and noticed the "Select" event, which says:

select "Off" when the user clicks on a visual object. To find out what was selected, call getSelection (). Is absent

and

setSelection () none Selects specific chart objects. Cancels any previous selection. Selected properties are regions with a designated value. The area correlates with a row in the data table (column index is zero). For this diagram, only one object can be selected at a time. Extended description.

Can I use this to get the record 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 it turned out that Milan was pressed? How can I do it? Or am I reading this wrong?

Google APIs for Geomaps http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html

The Google Group says there are no click events in marker mode: https://groups.google.com/forum/?fromgroups#!topic/google-visualization-api/K8uJoes8ZH0

+4
source share
1 answer

You need to call the getSelection function when calling select event. This function returns an array of objects. Each object has row and column attributes (if any). Use row and first column (0) to get label name (Rome, Milan, ...).

Example ( http://jsfiddle.net/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 the documentation to learn more about getSelection .

+8
source

Source: https://habr.com/ru/post/1402635/


All Articles