0

A map I created last year using Google Maps API V3 and Fusion Tables V1 has stopped functioning properly in the last week or so. I am not sure if I missed an update that has deprecated my code or if there's another explanation. In brief, the following code queries my fusion table and if a match is found it returns data for an info window. However, it is now returning false every time. The addInfoWindow() function is firing fine. The issue appears to be either in the query itself or the data that's returned. Additionally, the pin is dropping in the correct location on the map so the coordinates are not the issue.

This issue can be replicated by entering an address in the field. For demonstration purposes, 9132 Kingston Pike 37923 should return true. Clicking inside any polygon will return the intended results.

Thank you for any guidance you can provide.

// query

var script = document.createElement('script');
    var url = ['https://www.googleapis.com/fusiontables/v1/query?'];
    url.push('sql=');
    var query = "SELECT * FROM " +
    tableid + " WHERE ST_INTERSECTS(geometry, CIRCLE(LATLNG(" + coordinate.lat() + "," + coordinate.lng() + "), 0.001))";
    var encodedQuery = encodeURIComponent(query);
    url.push(encodedQuery);
    url.push('&callback=addInfoWindow');
    url.push('&key=' + apiKey);
    script.src = url.join('');
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(script);

// call back function

function addInfoWindow(data) {

infowindow.close();
initialize();

var rows = data['rows'];

if (rows)
    {
        console.log("inside if statement");
            for (var i = 0; i < 1; i++)
            {
                        console.log("inside for loop: " + rows[i][0]); 
            infowindow.setContent("<div style='width:250px;'><h2>"+ rows[i][1] + "</h2><p>The neighborhood contact in your area would love to hear from you! </p><p>Click <a href='https://cspctystn.infellowship.com/GroupSearch/ShowGroup/" + rows[i][0] + "' target='_blank'>here</a> to get their information.</p><p>&nbsp;</p><p>If you desire to communicate with Community Life staff, contact -- removed --.<p><br/><br/></div>");
//console.log(rows[i][1] + ": " + rows[i][0]);
        infowindow.setPosition(coordinate);
            map.setCenter(coordinate);
        map.setZoom(15);
            infowindow.open(map);

    }
}
else
{
        console.log("error"); 
    infowindow.setContent("<div style='width:250px;'><h2>Oops!</h1><p> It seems we don't have a neighborhood contact in your area.</p><p>Please communicate with our <a href='http://www.cspc.net/communitylife' target= '_blank' >Community Life</a> staff for more information.  -- removed --<p></div>");
    infowindow.setPosition(coordinate);
        map.setCenter(coordinate);
    map.setZoom(15);
        infowindow.open(map);
    }

}
mcmonty
  • 83
  • 1
  • 9
  • What does initialize() do? Do you have a jsfiddle or a link to a map that exhibits the problem? – geocodezip Feb 24 '14 at 15:53
  • @Dr.Molle, the tableid is 1YF3SH4YlHwlFuoWR-1GGHyJeZbR2AlM9RGmClP8. – mcmonty Feb 24 '14 at 17:16
  • Sorry, @geocodezip, I intended to link to the map. See updated question. Also, initialize() draws the map. – mcmonty Feb 24 '14 at 17:17
  • 2
    The request returns an error 403(Forbidden). The download-option for the table must be enabled(it isn't currently) to be able to query for data – Dr.Molle Feb 24 '14 at 17:24
  • How could it have worked before? Did you disable downloads at some point? – geocodezip Feb 24 '14 at 23:33
  • @geocodezip, I did not disable downloads. I'm not clear on how that setting was either introduced or switched off. I assume it is related to Fusion Tables still being an experimental app. – mcmonty Feb 25 '14 at 10:20
  • 1
    @geocodezip : there has been an issue, I had a fusionTable which was accessible via the API although the download was disabled( http://stackoverflow.com/a/21638270/459897 ) . I had reported this and yesterday I got the answer that it's fixed now. I guess it has been the same issue here, the table was accessible although it shouldn't , and with the fix it wasn't accessible anymore. – Dr.Molle Feb 25 '14 at 16:52
  • That would certainly explain it. Didn't know that happened. – geocodezip Feb 25 '14 at 19:11

0 Answers0