简体   繁体   中英

Unable to display GeoChart zoomOut button

I try to use geochart api. This api is latest one and few information.

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {
        'packages': ['geochart'],
        'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
      });
      google.charts.setOnLoadCallback(drawRegionsMap);

      function drawRegionsMap() {
        var data = google.visualization.arrayToDataTable([
          ['Country', 'Popularity'],
          ['Germany', 200],
          ['United States', 300],
          ['Brazil', 400],
          ['Canada', 500],
          ['France', 600],
          ['Russia', 700]
          //['RU', 700]
        ]);

        var options = {
          backgroundColor: '#81d4fa',
          showZoomOut: true,
        };
        console.log("showZoomOut=" + options.showZoomOut);
        var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
        google.visualization.events.addListener(chart, "zoomOut", function(){
          options.region = "world";
          console.log(options.region);
          chart.draw(data, options);        
        });

        google.visualization.events.addListener(chart, 'regionClick', function(r) {
          console.log(r);
          options.region = r.region;
          chart.draw(data, options);
        });
        chart.draw(data, options);
      }
    </script>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title></title>
  </head>
  <body>
    <div id="regions_div" style="width; 900px; height: 500px;"></div>
  </body>
</html>

showZoomOut option is already true. But zoomButton is not displayed. Documents is here enter link description here

enter image description here I expect to display like this zoomButton.

This question is resolved by myself.

zoomButton is supported only geomap. GeoChart is unavailable to apply it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM