Deprecated
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 tabbed content

This relates to Data Driven Mapping applications and the javaScript ‘howTo’
section.

For this example I had created a  Concerts/Venues example that is now deprecated. The complete workbook (googlemapping.xlsm) can be downloaded (above) and the example Parameter WorkSheet is called VenuesParameters.

How to create a tabbed InfoWindow

Prior to Google Mapping V3, there was a built in way to do this that seems to have now disappeared. Here is how to use javaScript and CSS to created a tabbed infoWindow (or any other tabbed web element for that matter.

Here’s an example screenshot from this example application.


The CSS

The use of css styles makes this whole process quite straightforward. The 2 key attributes are

  1. Borders. Changing the borders gives the impression that a particular tab has been ‘selected’
  2. Hiding elements. Changing the visibility of each tab blocks allows you to show the selected content.
The required css classes and the explanations are given below
  1. mcli. This class is applied to each element that makes up the list of tab names, for example <li class=’mcli’>World</li>.  They key items here are ‘inline’ to keep it all on the same line, and the rounded top right and top left corners (browser permitting). This gives us this effect
  2. mctabselected. When one of the tabs is selected we show that by removing the border from the tab and making it appear to merge into the tab content. You can do this by simply changing the background color and the bottom border color to the same as the background color of the tab content.
  3. mchover. This class is applied to the hover state of each of the tab elements to give this effect as the mouse passes over
  4. mcselected. This class is applied to a selected tab content element. each of the corners apart from the top left are given a rounded corner (browser permitting). This allows the tab border and the top left corner to merge.
  5. mchide and mcshow. These are applied to the tab content elements when they are selected.

The javaScript

The javascript to make this happen are part of a larger application, but you can extract the intent from the snippets below

set up the class names for later use

when you create a tab, add a click event to call a function that changes content and class

when a tab is selected – change its tab and content class

when a tab is not selected – change its tab and content class

browser independent add event function you’ll need

add to infoWindow .. Maps and Earth Version are not too different, except we need to be concerned with asynchronicity with Earth.

As with Flying around with Google Earth things going on in the Google Earth viewport, such as building layers in progress, can destablize the plotting of a balloon. Although IE and Chrome seemed to be able to handle this ok, Firefox would always hang. To get round this, we are going to handle the viewchangeend event to minimize this happening.

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