mcmontyCS
asked on
callback with Google Maps API v 3 and Google Fusion Table API v1
I'm attempting to retrieve data from a Google Fusion table using
Using console.log("pin clicked"), I can confirm that addInfoWindow() is being launched. However, the corresponding infoWindow doesn't open. The problem is how I'm trying to receive the data in the response.
https://developers.google. com/fusion tables/doc s/samples/ mouseover_ map_styles recommends to do it this way:
I never make it in the for loop when this script runs, though.
var script = document.createElement("script");
script.setAttribute("src","https://www.googleapis.com/fusiontables/v1/query?sql=SELECT * FROM " +
tableid + " WHERE ST_INTERSECTS(geometry, CIRCLE(LATLNG(" + coordinate.lat() + "," + coordinate.lng() + ", 0.001))&callback=addInfoWindow&key=" + apiKey);
document.getElementsByTagName("head")[0].appendChild(script);
Using console.log("pin clicked"), I can confirm that addInfoWindow() is being launched. However, the corresponding infoWindow doesn't open. The problem is how I'm trying to receive the data in the response.
https://developers.google.
// reduced from the actual version for simplicity sake
function addInfoWindow(data) {
infowindow.close();
var rows = data['rows'];
for (var i in rows) {
if (rows[i][0]['name'] != '')
{
initialize();
infowindow.setContent(rows[i][0]['name']);
}
else
{
initialize();
infowindow.setContent("nothing");
}
infowindow.setPosition(coordinate);
map.setCenter(coordinate);
map.setZoom(15);
infowindow.open(map);
}
I never make it in the for loop when this script runs, though.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window