My general outline is to have you
- Using a sample csv dataset
- upload that into Fusion Table, geocode it.
- Practice viewing the data on a fusion table map.
- Explore the Fusion Table SQL.
- Create a javascript html page the can query the fusion table data
- Create a simple Chrome Plugin
- Have the plugin query the fusion table data.
Google Fusion Tables
The primary location for documentation and references is https://developers.google.com/fusiontables/
1 - Using a sample csv dataset
Starting with a simple example. Let's map all the White Castles in MN, ( as scraped by loving hands from http://www.whitecastle.com/locations/all) Download the MNWhiteCastle CSV file here.. (open and save as or right click and save destination, you know the drill).
Now select all rows. SELECT * FROM DOCID
huh. Pretty quickly I hit a limit. So tacking on your API Key helps. Get that from
Note, the response is JSON, in the order it is in the table.
So.... Check this out you can do spacial operations on the query. Like say show me the 10 white castles closest to Leal Tillman (44.884779,-93.000282). We need some tools
2 - upload that into Fusion Table, geocode it.
In your Google drive folder, create a new document, choose More, then Fusion Tables.
Follow the steps and upload the CSV. Change the name if you like, don't worry too much about other settings, they should be good. You should now have a Fusion Table that looks like
The Address column is already highlighted because it recognizes it as an Address Type field. Since it saw it was an address field, a Map of Address tab was also created. Go ahead and click there. It will geocode the addresses and display a map. YAY. You mapped a bunch of addresses. If you chance you table structure you can go to File -> Geocode and it will geocode new addresses.
3 - AGAIN WITH MORE DATA
- FriendFace dataset
- This time the data is already geocoded, but labeled differently. You have to specify the lat lon as the address.
- Go to Edit->Change column
- Change lat to type = location, make it a two column field, and make the two columns lat and lon.
Add a tab to the Fusion Table of a "Map". You should now see your data points. BAM! Like that you mapped 1000 points. Nice work!
4 - Explore the Fusion Table SQL.
https://developers.google.com/fusiontables/docs/v1/sql-reference has a good description of what you can do with your FusionTable data now that it is up there. First, set the permissions of your table so that it is viewable to anyone with the link.
Make a note of the docid of your table.
Now select all rows. SELECT * FROM DOCID
https://www.googleapis.com/fusiontables/v1/query?sql= SELECT * FROM 1t3pUD-6Nt2i9tCZpSC_gi3-H0AL1tpO5TGAsCLw
huh. Pretty quickly I hit a limit. So tacking on your API Key helps. Get that from
https://code.google.com/apis/console
https://www.googleapis.com/fusiontables/v1/query?sql=SELECT * FROM 1t3pUD-6Nt2i9tCZpSC_gi3-H0AL1tpO5TGAsCLw&key=<>
Note, the response is JSON, in the order it is in the table.
So.... Check this out you can do spacial operations on the query. Like say show me the 10 white castles closest to Leal Tillman (44.884779,-93.000282). We need some tools
- Fusion Tables distance function: ST_DISTANCE(<
>,< >) - Define a point: LATLON(44.884779,-93.000282), in Lael's case.
so:
SELECT *
FROM [table]
ORDER BY ST_DISTANCE(Address,LATLNG(44.884779,-93.000282))
5 - Create a javascript html page the can query the fusion table data
Let's play with Intersect, like on this example: Fusion Tables Layer Example: Intersects Radius
- Copy the HTML from the above link. Save it somewhere locally. I called it circle.html
- It won't work because you need the css. It's here.
- update the circle.html file.
- Line23. Chance the css to be
default.css" rel="stylesheet" type="text/css">
37.4, -122.1
to
44.988265,-93.259191 (Code42's office)
YOU SHOULD FIND 4
NOW load the page.
TAHDAH......
Note: when you change the select box, the radius updates and re-queries the data.
Note: when you change the select box, the radius updates and re-queries the data.