Created
January 15, 2014 01:32
-
-
Save dacook/8429240 to your computer and use it in GitHub Desktop.
Simple Javascript function to test a google.maps.FusionTablesQuery object, with JSON response.
More improvements can be made..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* fusionTablesQuery() | |
* | |
* Query a Fusion Table with JSON response. | |
* | |
* Parameters: | |
* @query: google.maps.FusionTablesQuery (only some options implemented so far) (ref: https://developers.google.com/maps/documentation/javascript/reference#FusionTablesQuery) | |
* @callback: function(jsonResult) | |
* | |
* Returns: void | |
* Throws: Error if server query error | |
* | |
*/ | |
fusionTablesQuery = function(query, callback) { | |
var sql = "SELECT " + query.select + " FROM " + query.from + (query.where ? " WHERE " + query.where : '') + (query.limit ? " LIMIT " + query.limit : '') //note: could create a clever loop to build this.. | |
var key = 'my key'; | |
$.getJSON(InfoBase_GeoMap.fusionTablesQueryUrl, {key: key, sql: sql}) | |
.success(function(response) { | |
// console.log(response); | |
callback(response); | |
}) | |
.fail(function(jqXHR, textStatus, errorThrown){ | |
throw new Error(textStatus + "\n" + errorThrown.toString(), errorThrown); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment