Google has now stopped its Earth API and Maps API is a paid for API nowadays. Some capabilities have also been either removed or changed. Therefore, I had to remove all examples of VizMap applications I had created. I didn’t remove the entire topic as I thought some of the code may still be useful with some modifications. 

javaScript:creating google visualization DataTables

This relates to Data Driven Mapping applications and the Javascript HowTo section

Google Visualization Tables

I have covered Google Visualization in various forms with an ‘Excel slant’ on this site. Let’s take a look at some useful google visualization related functions.

waiting for the document to load

A typical technique for waiting for the whole page to load before calling your javascript is to use the <body “onload=foo()”> type of technique. Since the <body> part of my application is tailorable,  I didn’t really want to expose that to random editing, so I used the very useful google.load.  This means it can get underway loading the packages I needed right away, calling back  ‘mcpherDrawEverything()’ when ready to go.

Creating a master data table

The way this works is that I create a google dataTable containing all the item data, and then create google dataView visualizations of that for each tab of each infoWindow. All this is done on initialization, then the selection of infowindow and tab data is simply a case of changing the CSS attributes of each element so they are display: block or display: none. Here is how to create the master table

Validating input data

The VizMap Dictionary contains a list of all the data items and their type. Since the dictionary and data might have been generated separately outside Excel, there is a chance that their type would not match, which would cause the google dataTable load to fail, since the incoming jSon data string may be representing the data as a string. Here are a few couple of functions to check that data type is good.  A dictionary will look like this.
These are the validating and converting functions.

Getting dataView aggregation types

Aggregation types for google dataView tables are some named google constants. Since VizMap Measures contain textual description of how to aggregate, I needed a simple function to convert them to their google equivalents.

As usual questions, feedback and comments are welcome at our forum. Now lets take a look at more javaScript snippets from this application