Google地图未在div悬停时加载

时间:2013-11-14 05:27:06

标签: google-maps

此代码块在页面加载时运行良好 -

   <script type="text/javascript">
    google.load("visualization", "1", { packages: ["map"] });
    google.setOnLoadCallback(drawMap);
    function drawMap() {
        var data = google.visualization.arrayToDataTable([
          ['Lat', 'Lon', 'Name'],
          [22.1589, 90.1165, 'BARGUNA'],
          [22.6953, 90.3538, 'BARISAL'],
         ]);
        var options = {
            showLine: false,
            showTip: true,
            zoomLevel: 7,
            mapType: 'terrain'
        };
        var map = new google.visualization.Map(document.getElementById('map_canvas'));
        map.draw(data, options);
    }
</script>

此代码块用于特定的div悬停事件。但它不起作用 -

<script>
      $(function () {
          $('#tab-dhakadivision').hover(function () {

              google.load("visualization", "1", { packages: ["map"] });
              google.setOnLoadCallback(drawMap);
              function drawMap() {
                  var data = google.visualization.arrayToDataTable([
                     ['Lat', 'Lon', 'Name'],
                      [23.78069, 90.41932, 'DHAKA'],
                      [23.60113, 89.83923, 'FARIDPUR'],
                      [24.11119, 90.42584, 'GAZIPUR']
                  ]);

                  var options = {
                      showLine: false,
                      showTip: true,
                      zoomLevel: 7,
                      mapType: 'terrain'
                  };

                  var dmap = new google.visualization.Map(document.getElementById('map_canvas'));
                  dmap.draw(data, options);
              }

          });

      });

  </script>

有什么建议吗?

0 个答案:

没有答案