You were looking in the right place. The regionClick event is thrown for
every region clicked, regardless of your data. It uses ISO codes to
describe the region identities, and does not supply any other names. This
event is mainly useful when you want to implement a zoom behavior for your
chart, where every click opens another map, by setting the 'region' option
to the ISO code in the event.

However, there is a reasonable work around for your case using the 'select'
event.
The 'select' event is only triggered when the user clicks a region with
data. Currently we do not support in GeoChart any visual effect for
selection, so the only thing that changes is the inner state of the chart,
which you can access by using the chart's getSelection() method. The return
value of getSelection() points to a row in your data table, so you can get
all the information you need from there. Just make sure to deselect the
selection (using setSelection()) when you handle the 'select' event,
otherwise the next click on the same region will de-select it and
getSelection() will return an empty array.

See example:
http://savedbythegoog.appspot.com/?id=8d9546002b2b33bd14160e11c6069e888ffa684b



On Fri, May 4, 2012 at 11:52 PM, David Nelson <[email protected]> wrote:

> Using GeoCharts is working great, but now I'm trying to figure out how to
> handle the event listener.
>
> I found some sample code for the eventData, but it's not exactly what I
> want and I'm not finding the documentation for this piece of it in the API.
>  I may just be looking in the wrong place.
>
> Two things to figure out.
> 1)  How to ignore clicks on Countries not on the list, for example in the
> data set below do nothing if clicking on Russia.
> 2)  How to return the Country name, not the ISO code that google uses.
>
> I'm sure I'm overlooking something obvious or just not reading the API
> correctly so any help would be appreciated.  Better yet, hints on where to
> read more detail about the eventData for the GeoChart API..
>
> Thanks,
> David
>
>
>       var data = google.visualization.arrayToDataTable([
>         ['Country', 'Presence'],
>           ['Brazil', 2],
>           ['Canada', 1],
>           ['China', 1],
>           ['United States', 5],
>       ]);
>
> google.visualization.events.addListener(geoChart, 'regionClick',
> function(eventData)
>     {
>     alert('You clicked on a region named: ' + eventData.region);
>     });
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-visualization-api/-/yY10WczO6x0J.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-visualization-api?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to