Hi, if you're using Chrome you can open the developer tools. From there,
you can go to the Console tab to see all your errors. Your particular error
is that within the context of selectHandler, chart is undefined, so
chart.getSelection can't work. You could solve this either by creating a
function that takes a chart and returns your handler function or by putting
the selectHandler inline. Personally, I prefer the latter option, but if
you have a lot of code in your select handler, I would not recommend it.

However, you may want to be listening for the 'select' event, instead of
the regionClick event.

On Wed Oct 22 2014 at 2:00:36 PM <dpwillia...@gmail.com> wrote:

> The coding gets to the first alert test in the selectHandler function but
> never gets to the second alert. Meaning that it stops at the var selection
> = chart.getSelection(); portion of code.
>
> I just can't figure it out.
>
>
> On Tuesday, October 21, 2014 2:28:06 PM UTC-7, dpwil...@gmail.com wrote:
>>
>> Hello guys,
>>
>> I'm having a problem with regionClick and getting the state that was
>> selected. I've included my code below and am probably missing something
>> really easy. Can any of you help me figure this out?
>>
>>
>>> google.setOnLoadCallback(drawRegionsMap);
>>>
>>> function drawRegionsMap() {
>>>     var data = google.visualization.arrayToDataTable([
>>>         ['States'],
>>>         ['Washington'],
>>>         ['Oregon'],
>>>         ['Idaho'],
>>>         ['Arizona'],
>>>         ['Utah']
>>>     ]);
>>>
>>>     var options = {
>>>         region: 'US',
>>>         dataMode: 'regions',
>>>         resolution:'provinces',
>>>         enableRegionInteractivity: true
>>>     };
>>>
>>>     var chart = new google.visualization.GeoChart(
>>> document.getElementById('regions_div'));
>>>
>>>     chart.draw(data, options);
>>>
>>>     google.visualization.events.addListener(chart, 'regionClick',
>>> selectHandler);
>>> }
>>>
>>> function selectHandler(e) {
>>>
>>>     alert('Test');
>>>
>>>     var selection = chart.getSelection();
>>>
>>>     alert('Second Test');
>>>
>>>     var state = data.getValue(selection[0].row,0);
>>>
>>>     alert('You selected ' + state);
>>>
>>>     switch(state){
>>>         case "Washington":
>>>             alert('Washington');
>>>             //window.location = "";
>>>             break;
>>>         case "Oregon":
>>>             alert('Oregon');
>>>             //window.location = "";
>>>             break;
>>>         case "Idaho":
>>>             alert('Idaho');
>>>             //window.location = "";
>>>             break;
>>>         case "Utah":
>>>             alert('Utah');
>>>             //window.location = "";
>>>             break;
>>>         case "Arizon":
>>>             alert('Arizon');
>>>             //window.location = "";
>>>             break;
>>>     }
>>> }
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-visualization-api+unsubscr...@googlegroups.com.
> To post to this group, send email to
> google-visualization-api@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/google-visualization-api.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to