I'm running query that looks like this:
var ready_data= $.getJSON('URL HERE', function (data) {
var id_value= data.rows.map(function (row) {
return [row[1]+","+ row[2]];
});
The var id_value comes back in my console log with something like this:
Array[1]]0: Array[1]0: "34.154321,-118.349126"length: 1__proto__: Array[0]1: Array[1]2: Array[1]3....
I'm only showing part of what's returned for clarity. But basically, I get back an array for each item that matches my query criteria from my getJSON (they're map coordinates).
What I want to do is put each of these arrays (one at a time) into a query and get back the results. Right now, I'm using this:
$.each(id_value,function(data) {
var key='MY API KEY'
var table ='TABLE NUMBER'
var sql = "SELECT COUNT() from " + table +
" WHERE ST_INTERSECTS(coordinates,CIRCLE(LATLNG("+id_value+"), 16093 ))";
url = "https://www.googleapis.com/fusiontables/v1/query?key=" + encodeURIComponent(key) + "&sql=" + encodeURIComponent(sql) + '&callback=?';
$.getJSON(url, function (data) {
$('#info2').append((data.rows ? data.rows[0] : 0) );
});
});
This doesn't work because it builds a query string with every single pair of coordinates in the same query instead of one query per array.
How should I be doing this so that I've got a functioning .each loop (or something totally different)?
... LATLNG("+id_value+"), ...looks like a genuine mistake to me. Ought to be... LATLNG("+data+"), ..., no?