Google Fusion API和显示所有数据的问题 [英] Google Fusion API and issues with displaying all the data

查看:72
本文介绍了Google Fusion API和显示所有数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是在科罗拉多州展示葡萄园.它显示自定义图标,它们位于正确的位置;但是,它不会显示所有数据.超过50个时,仅显示11个点.反正还有吗?

What I am trying to do is display vineyards in Colorado. It displays the custom icons and they are in the correct places; however, it does not display all the data. Only 11 points are being showed when there is over 50 of them. Is there anyway around this?

编辑:这也是我的Google Fusion表.也许我的格式是错误的? https://www.google.com/fusiontables/DataSource?docid = 1pYFq7mJ1uT4YYZ3LLzY4l7X8njLmZszJt05lucY#rows:id = 1

Here is also my Google Fusion table. Perhaps my formatting is wrong? https://www.google.com/fusiontables/DataSource?docid=1pYFq7mJ1uT4YYZ3LLzY4l7X8njLmZszJt05lucY#rows:id=1

将Fusion地图与此进行比较: http://s5.postimg.org/f80q3qhpz/display .png

Compare the Fusion map to this: http://s5.postimg.org/f80q3qhpz/display.png

这是我的HTML和Javascript.

Here is my HTML and Javascript.

<!DOCTYPE html>

<!--

-->

<html>
<head>
<title>Vineyards in Colorado</title>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<!-- Style -->
<style type="text/css">
  body { height: 100%; margin: 0px; padding: 10px; }
  #map_canvas { height: 600px; width: 700px; }
</style>

<!-- Google Maps API javascript -->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<!-- Import the visualization javascript -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<!-- Initialize visualization -->
<script type="text/javascript">
  google.load('visualization', '1', {});
</script>

<script type="text/javascript">

var tableid = 1; //the table id
var map;

/* INITIALIZE - initialize the map and geocoder */

function initialize() {
  geocoder = new google.maps.Geocoder();
  map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: new google.maps.LatLng(39,-105.547222), //the center lat and long
    zoom: 7, //zoom
    mapTypeId: google.maps.MapTypeId.ROADMAP //the map style
  });

  //make gviz request
  setData();

}

/* GVIZ - get data from Fusion Tables */

function setData() {
  //create a viz query to send to Fusion Tables
  var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' + encodeURIComponent("SELECT name, address FROM 1pYFq7mJ1uT4YYZ3LLzY4l7X8njLmZszJt05lucY"));

  //set the callback function that will be called when the query returns
  query.send(getData);
}

//define callback function, this is called when the results are returned
function getData(response) {

  //for more information on the response object, see the documentation
  //http://code.google.com/apis/visualization/documentation/reference.html#QueryResponse
  numRows = response.getDataTable().getNumberOfRows();
  numCols = response.getDataTable().getNumberOfColumns();

  //create an array of row values
  for (i = 0; i < numRows; i++) {
    var row = [];
    for (j = 0; j < numCols; j++) {
      row.push(response.getDataTable().getValue(i, j));
    }
    codeAddress(row);
  }
}

/* GEOCODING - geocode data in Fusion Tables, if the data is a String Address */

var geocoder;
var lastWindow;

//geocode the address, and create a new marker and InfoWindow at the geocoded location
function codeAddress(row) {
  geocoder.geocode( { 'address': row[1] }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      var coordinate = results[0].geometry.location;

      //create the marker
      var marker = new google.maps.Marker({
          map: map, 
          position: coordinate,
          //this is where the magic happens!
          icon: new google.maps.MarkerImage("http://s5.postimg.org/icgrcg88j/vineyard_2.png")
      });

      //add a click listener to the marker to open an InfoWindow,
      google.maps.event.addListener(marker, 'click', function(event) {
        if(lastWindow) lastWindow.close(); //close the last window if it exists
        lastWindow = new google.maps.InfoWindow( {
          position: coordinate,
          content: row[0] //this is the row data, you can use HTML here for the content
        });
        lastWindow.open(map);
      });
    } 
  });
}


</script>

</head>
<body onload="initialize()">
  <div id="map_canvas"></div>
</body>
</html>

推荐答案

您正在对地址进行地理编码,这将导致OVER_QUERY_LIMIT错误(大约10个左右):

You are geocoding the addresses, that will run into OVER_QUERY_LIMIT errors (at about 10 or so):

添加其他类似内容以查看它们:

Add an else like this to see them:

if (status == google.maps.GeocoderStatus.OK) {
// .. your code
} else { 
  alert("geocode failed:"+status); 
}

您在表格中有经度和纬度,可使用它们显示标记,而无需使用地理编码器.

You have the latitude and longitude in the table, use them to display the marker, don't use the geocoder.

通过FusionTableLayer您的数据

这篇关于Google Fusion API和显示所有数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆