Five Great Fusion Tables + Maps Examples

WikiEDdata – Mapping Poverty in Washington School Districts


The most powerful maps allow users to quickly understand the significance of large amounts of data. Using Fusion Tables, polygons representing school districts and poverty levels are rendered and colored based on their assigned values in the tables.

Clicking on a district polygon will bring up an infowindow containing a poverty line data chart, dynamically generated through the Google Chart API.

Reporting Road Potholes in Spain


Fusion Tables makes crowdsourcing easy. Using Fusion Tables, Otrobache.com allows Madrid citizens to log on and report the location of potholes. The newly reported potholes appear on the map in real time (as soon as the map is refreshed).

The Telegraph – UK Charities Map


Fusion Tables is a great way to store and quickly render large amounts of data. The Telegraph used Fusion Tables to catalog and map literally tens of thousands of charities throughout the UK.

Analyzing Concealed Handgun Licenses in San Antonio


From San Antonio Express-News, “The Texas Tribune analyzed a Department of Public Safety database that tracks concealed handgun licenses in Texas. The Tribune’s analysis found that the number of gun permits in an area often correlates with income and political beliefs.”

Fusion Tables is used here to overlay the data with boundaries and view possible correlations. The implementation also makes use of Gradient styling. Gradients allows developers to specify a color ramp and a number range; features will be displayed in the color appropriate for where they belong in the range. Much like the built-in Intensity map visualization, but now you can change the colors and use your own boundaries!

Boris Bikes on Fusion Tables


Using geometry styling controls in Fusion tables, this implementation is a live visualization of London Cycle Hire Rank availability using data from the Boris Bikes API.

Instant Previews: Under the hood

If you’ve used Google Search recently, you may have noticed a new feature that we’re calling Instant Previews. By clicking on the (sprited) magnifying glass icon next to a search result you see a preview of that page, often with the relevant content highlighted. Once activated, you can mouse over the rest of the results and quickly (instantly!) see previews of those search results, too.

Adding this feature to Google Search involved a lot of client-side Javascript. Being Google, we had to make sure we could deliver this feature without slowing down the page. We know our users want their results fast. So we thought we’d share some techniques involved in making this new feature fast.

JavaScript compilation

This is nothing new for Google Search: all our Javascript is compiled to make it as small as possible. We use the open-sourced Closure Compiler. In addition to minimizing the Javascript code, it also re-writes expressions, reuses variables, and prunes out code that is not being used. The Javascript on the search results page is deferred, and also cached very aggressively on the client side so that it’s not downloaded more than once per version.

On-demand JSONP

When you activate Instant Previews, the result previews are requested by your web browser.
There are several ways to fetch the data we need using Javascript. The most popular techniques are XmlHttpRequest (XHR) and JSONP. XHR generally gives you better control and error-handling, but it has two drawbacks: browsers caching tends to be less reliable, and only same-origin requests are permitted (this is starting to change with modern browsers and cross-origin resource sharing, though). With JSONP, on the other hand, the requested script returns the desired data as a JSON object wrapped in a Javascript callback function, which in our case looks something like

google.vs.r({"dim":[302,585],"url":"http://example.com",ssegs:[...]}).

Although error handling with JSONP is a bit harder to do compared to XHR (not all browsers support onerror events), JSONP can be cached aggressively by the browser, and is not subject to same-origin restrictions. This last point is important for Instant Previews because web browsers restrict the number of concurrent requests that they send to any one host. Using a different host for the preview requests means that we don’t block other requests in the page.

There are a couple of tricks when using JSONP that are worth noting:

  • If you insert the script tag directly, e.g. using document.createElement, some browsers will show the page as still “loading” until all script requests are finished. To avoid that, make your DOM call to insert the script tag inside a window.setTimeout call.
  • After your requests come back and your callbacks are done, it’s a good idea to set your script src to null, and remove the tag. On some browsers, allowing too many script tags to accumulate over time may slow everything down.

Data URIs

At this point you are probably curious as to what we’re returning in our JSONP calls, and in particular, why we are using JSON and not just plain images. Perhaps you even used Firebug or your browser’s Developer Tools to examine the Instant Previews requests. If so, you will have noticed that we send back the image data as sets of data URIs. Data URIs are base64 encodings of image data, that modern browsers (IE8+, Chrome, Safari, Firefox, Opera, etc) can use to display images, instead of loading them from a server as usual.

To show previews, we need the image, and the relevant content of the page for the particular query, with bounding boxes that we draw on top of the image to show where that content appears on the page. If we used static images, we’d need to make one request for the content and one request for the image; using JSONP with data URIs, we make just one request. Data URIs are limited to 32K on IE8, so we send “slices” that are all under that limit, and then use Javascript to generate the necessary image tags to display them. And even though base64 encoding adds about 33% to the size of the image, our tests showed that gzip-compressed data URIs are comparable in size to the original JPEGs.

We use caching throughout our implementation, but it’s important to not forget about client-side caching as well. By using JSONP and data URIs, we limit the number of requests made, and also make sure that the browser will cache the data, so that if you refresh a page or redo a query, you should get the previews, well… instantly!

By Matías Pelenur, Instant Previews team

Enough With the Mashups Already!

It seems like a day doesn’t go by where some company puts out some press release about some edge case implementation of their mapping api. I couldn’t care less guys.

Unless the implementation is built into how we as consumers use information (type it into my browser search bar, type it into my smartphone) there isn’t any way I’ll actually use it. Plus as a developer, you should be offering me the feed up so I can implement it in my own stack, not locking it up behind some weird specialized mashup UI.

Wonder what tomorrow’s secret mashup ingredient will be…