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?
Asked
Active
Viewed 488 times
0
-
EDIT: My sample [map link is here](http://jsfiddle.net/S2WMf/2/) – mpsbhat Apr 25 '13 at 07:11
1 Answers
0
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]));

Community
- 1
- 1

Eric Bridger
- 3,751
- 1
- 19
- 34
-
-
There is sample code in the answer linked above. Look at the second example: getFTCount() but change the query Head and Tail var's. – Eric Bridger May 01 '13 at 18:11
-
Yes. The example just does an alert(count) when the count is returned but you could do whatever you want with it. Store it in a global then redraw your legend. – Eric Bridger May 02 '13 at 21:17
-
I updated my sample [map here](http://jsfiddle.net/S2WMf/3/). It didn't working with FT API v1 – mpsbhat May 13 '13 at 10:32