Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:59:18+00:00 2026-05-22T15:59:18+00:00

google.visualization.events.addListener( geomap, regionClick, function(e) { console.log(e[region]); console.log(data.getValue(e[region],1)); }); I use this code to see

  • 0
google.visualization.events.addListener( 
          geomap, "regionClick", function(e) {
          console.log(e["region"]);
          console.log(data.getValue(e["region"],1));
          }); 

I use this code to see which region is clicked. The e["region"] gives the row number of that region, and then I use getValue to see the region(marker) name.

Now, in the console log shows up this error:

Uncaught Error: Invalid row index 1. Should be in the range [0-14]

How can the row index 1 be invalid, as it is in the range [0-14] ?

EDIT:

There you go, more code 🙂

     <!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Google Visualization API Sample</title>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript">

   google.load("visualization", "1", {"packages": ["geomap"]});

   google.setOnLoadCallback(drawMap);



    function drawMap() {

      var data = new google.visualization.DataTable();

      data.addRows(24);

      data.addColumn("string", "City");

      data.addColumn("number", "Numar anunturi");data.setValue(0, 0, 'Ilfov');

    data.setValue(0, 1, 19);



     data.setValue(1, 0, 'Giurgiu');

    data.setValue(1, 1, 7);



     data.setValue(2, 0, 'Brasov');

    data.setValue(2, 1, 6);



     data.setValue(3, 0, 'Buzau');

    data.setValue(3, 1, 3);



     data.setValue(4, 0, 'Valcea');

    data.setValue(4, 1, 3);



     data.setValue(5, 0, 'Dolj');

    data.setValue(5, 1, 3);



     data.setValue(6, 0, 'Neamt');

    data.setValue(6, 1, 2);



     data.setValue(7, 0, 'Calarasi');

    data.setValue(7, 1, 2);



     data.setValue(8, 0, 'Dambovita');

    data.setValue(8, 1, 2);



     data.setValue(9, 0, 'Prahova');

    data.setValue(9, 1, 2);



     data.setValue(10, 0, 'Braila');

    data.setValue(10, 1, 2);



     data.setValue(11, 0, 'Constanta');

    data.setValue(11, 1, 2);



     data.setValue(12, 0, 'Suceava');

    data.setValue(12, 1, 2);



     data.setValue(13, 0, 'Caras-Severin');

    data.setValue(13, 1, 2);



     data.setValue(14, 0, 'Cluj');

    data.setValue(14, 1, 2);



     data.setValue(15, 0, 'Bihor');

    data.setValue(15, 1, 1);



     data.setValue(16, 0, 'Bacau');

    data.setValue(16, 1, 1);



     data.setValue(17, 0, 'Maramures');

    data.setValue(17, 1, 1);



     data.setValue(18, 0, 'Arges');

    data.setValue(18, 1, 1);



     data.setValue(19, 0, 'Gorj');

    data.setValue(19, 1, 1);



     data.setValue(20, 0, 'Ialomita');

    data.setValue(20, 1, 1);



     data.setValue(21, 0, 'Bucuresti');

    data.setValue(21, 1, 1);



     data.setValue(22, 0, 'Mures');

    data.setValue(22, 1, 1);



     data.setValue(23, 0, 'Sibiu');

    data.setValue(23, 1, 1);





      var options = {width: 800,height:400};

      options["region"] = "RO";

      options["colors"] = [0xFF8747, 0xFFB581, 0xc06000]; //orange colors

      options["dataMode"] = "markers";



      var container = document.getElementById("map_chart_div");

      var geomap = new google.visualization.GeoMap(container);

        google.visualization.events.addListener( 
          geomap, "regionClick", function(e) {
          console.log(e["region"]);
          console.log(data.getValue(e["region"],1));
          }); 

      geomap.draw(data, options);

    }

  </script> 
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="map_chart_div" style="width: 800px; height: 400px;"></div>
</body>
</html>
​
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:59:19+00:00Added an answer on May 22, 2026 at 3:59 pm

    I can’t reproduce your problem with the code you’ve posted – I can’t seem to get the regionClick function to fire at all – but the error message you’re seeing makes me suspect that your problem is that e["region"] is returning a string, not a number.

    Try adding this to your function:

    google.visualization.events.addListener( 
              geomap, "regionClick", function(e) {
              console.log(e["region"]);
              console.log("Type of value is: " + typeof(e["region"]));
              console.log(data.getValue(e["region"],1));
              }); 
    

    Then, if it turns out you are getting a string, you might try:

    google.visualization.events.addListener( 
              geomap, "regionClick", function(e) {
              console.log(e["region"]);
              console.log("Type of value is: " + typeof(e["region"]));
              console.log(data.getValue(Math.floor(e["region"]),1));
              }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Google visualization for drawing graphs into my website. This involves
Is there anyway to have an export function to export the Google Visualization organizational
Google maps in some region can serve traffic information showing the blocked roads and
Google's not coming to my rescue, here, and I just know this is the
Google results on this one are a bit thin, but suggest that it is
Google chrome doesn't behave the same as other browsers when encountering this nugget: <?php
Google is failing me on this one. Let's say I have some ECMA script
In Google Reader, you can use a bookmarklet to note a page you're visiting.
Does anyone know if I can hack google's visualization ColumnChart api chart somehow, to
I have a Google Chart (using the Google Visualization API , not Google Charts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.