Marker count in fusion table map

无人久伴 提交于 2019-12-12 03:03:27

问题


I went through these two links: first and second which explains how to add count of marker in fusion table map layer. I tried the same technique in my sample map but it didn't work. Actually i need the count of critical, optimal, normal transforers seperately and the total of all. Also i want to know that can I add these counts in map legend?


回答1:


Over a year ago, I posted an answer with example code which is the same approach taken in your "first" link. https://stackoverflow.com/a/9778985. See the getFTCount() function. The problem with both these examples is that they are old and use the deprecated FT SQL API, not the V1.0 API.

You will need a Google API key. And jQuery. The one thing you'll need to change in the code is:

var apiKey = "XXXXXX";
var queryUrlHead = 'https://www.googleapis.com/fusiontables/v1/query?sql=';
var queryUrlTail = '&key=' + apiKey + '&callback=?';

Update: I fixed your jsfiddle to make it work. Couple of issues:

  • The new api returns data.columns and data.rows, not data.table.rows.
  • I guess the new API is returning json integers, not strings and jquery seems to object to passing numbers to $("#div_id").html() or .append().

Note: the empty string before the count number

$('#count').html(('' + data.rows[0]));

http://jsfiddle.net/S2WMf/8/



来源:https://stackoverflow.com/questions/16208502/marker-count-in-fusion-table-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!