170 likes | 478 Views
Google Fusion Tables API. Inneke Ponet. Google Fusion Tables. Google Fusion Tables: S tore, share, query and visualize data. API to run SQL-like queries applications that use Fusion Tables as a database. Writing an application. Send API statements to Goolge Fusion Tables:
E N D
Google Fusion Tables API Inneke Ponet
Google Fusion Tables Google Fusion Tables: • Store, share, query and visualize data. • API to run SQL-like queries applications that use Fusion Tables as a database.
Writinganapplication • Send API statements to Goolge Fusion Tables: • queries: HTTP GET requests; • inserts, updates and deletes: HTTP POST requests. • The API is language agnostic. • It doesn’t have a mechanism for submitting the GET and POST requests. Use existing code libraries (Java, Javascript, .NET, PHP, Python, Objective-C).
Query example • Exploring tables • https://www.google.com/fusiontables/api/query?sql=SHOW TABLES tableid,name 274409,StoreInventory https://www.google.com/fusiontables/api/query?sql=DESCRIBE 274409 column id,name,type col0,Product,string col1,Inventory,number
Fusion Tables with other APIs • Google Maps API • Fusion Tables Layer • Google Chart Tools • Data source
Google Maps • Geographic data in a Fusion Table: • Geocode of a street address, a name of a city, a name of a country; • latitude, longitude pair; • KML. • FusionTablesLayer: • interface to a Fusion Table, • automatic rendering of the location data, • clickable overlays.
Example Google Maps var chicago = new google.maps.LatLng(41.948766, -87.691497);map = new google.maps.Map(document.getElementById('map_canvas'), {center: chicago, zoom: 12,mapTypeId: 'roadmap'});var layer = new google.maps.FusionTablesLayer({ query: { select: 'address',from: '198945',where: 'ridership > 5000' }});layer.setMap(map);
Example Google Chart google.load('visualization', '1', {'packages':['corechart']}); functionchangeData() { var queryText = encodeURIComponent( "SELECT Year, Austria, Bulgaria, Denmark, Greece FROM 641716"); var query = new google.visualization.Query( 'http://www.google.com/fusiontables/gvizdata?tq=' + queryText); query.send(getData); } functiongetData(response) { new google.visualization.BarChart(document.getElementById('visualization')). draw(response.getDataTable(), {title:"Yearly Coffee Consumptionby Country", width:600, height:400, vAxis: {title: "Year"}, hAxis: {title: "Cups"}} ); }
Example Google Chart 2 google.load('visualization', '1'); functionloadData(year) { var queryText = encodeURIComponent( "SELECT 'Male name', 'Reverse rank‘ FROM 642040 WHERE year = '" + year + "‘ ORDER BY 'Male name'"); var query = new google.visualization.Query( 'http://www.google.com/fusiontables/gvizdata?tq=' + queryText); query.send(getData); } functiongetData(response) { var outputDiv = document.getElementById('visualization'); var tc = new TermCloud(outputDiv); tc.draw(response.getDataTable(), null); }
Example Fusion Tables http://www.google.com/fusiontables/DataSource?dsrcid=851292 <iframe width="500px" height="300px" scrolling="no" src="http://www.google.com/fusiontables/embedviz?viz=MAP&q=select+col0%2C+col1%2C+col2%2C+col3+from+851292+&h=false&lat=51.020456&lng=4.899438550000001&z=10&t=1&l=col2"></iframe>
Fusion Tables in other applications • Custom applications (HTTP GET and POST). • Google Maps with FusionTableLayer. • Google Chart and Fusion Tables as data source. • Visualization in an HTML page.