本文介绍了将 FusionTablesLayer 与 Google Maps JavaScript API v3 一起使用时的空白页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用融合表的数据准备了一个简单的页面.( FusionTablesLayer 与 Google Maps JavaScript API v3 )但未显示地图.您可以在此处查看该页面:http://www.siterary.com/0test.html.有什么问题 ?代码如下

I prepared a simple page by using the data of a fusion table. ( FusionTablesLayer with Google Maps JavaScript API v3 ) but the map is not displayed. You can see the page here: http://www.siterary.com/0test.html . What's the problem ? The code is as below

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>test</title>
    <link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBK_ErFIm-CYBsslK_9ZB6m0wPV197UaJg&sensor=false"></script>
    <script>

      function initialize() {

        var  istanbul = new google.maps.LatLng(41.01, 28.97);

        map = new google.maps.Map(document.getElementById('map_canvas'), {
          center: istanbul,
          zoom: 11,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        layer = new google.maps.FusionTablesLayer({
          query: {
            select:  'Location' ,
            from: '1s3DYRvmNAfKgo-swjG39-8UEb9tHMm0UPHvW_tc'
          }
        });
        layer.setMap(map);
      }
    </script>
  </head>
  <body onload="initialize()">

<B>MAP</B> <BR>

    <div id="map_canvas"></div>
  </body>
</html>

推荐答案

您的站点上不存在文件/maps/documentation/javascript/examples/default.css".您的地图没有有效的尺寸.

The file "/maps/documentation/javascript/examples/default.css" doesn't exist on your site. Your map doesn't have a valid size.

工作版

代码片段:

function initialize() {

  var istanbul = new google.maps.LatLng(41.01, 28.97);

  map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: istanbul,
    zoom: 11,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

  layer = new google.maps.FusionTablesLayer({
    query: {
      select: 'Location',
      from: '1s3DYRvmNAfKgo-swjG39-8UEb9tHMm0UPHvW_tc'
    }
  });
  layer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}
#map_canvas {
  height: 100%;
}
@media print {
  html,
  body {
    height: auto;
  }
  #map_canvas {
    height: 650px;
  }
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<B>MAP</B>
<BR>

<div id="map_canvas"></div>

这篇关于将 FusionTablesLayer 与 Google Maps JavaScript API v3 一起使用时的空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 21:35