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: Flying around and asynchronicity in google Earth

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

Google Earth Api

You will find tons of content on Google Earth , most of which is described much better than I can. In this section I will cover the small items of interest that I found to be hard to track down when I was developing this application (now deprecated)

Checking if the the Google Earth Plugin is installed

Not everyone will have the google earth plug-in. Here is how to check whether it is installed

Creating an Instance

Because I am using the same code for google maps and google earth, I have some wrapper objects so I can  add extra properties. In this case mcpherEarth is my wrapper object for the Earth Instance.
I had originally planned for the success and failure callbacks to be methods of this wrapper object but I just could not get that to work, so i created a couple of regular functions which in turn called back the methods I had originally wanted to use.

Success Callback

In the google maps version of the application, it’s okay to create a bounding box and leave it to the user to select which marker to go to. On Google Earth it’s not so practical, so I decided to zoom into the the first data spot as the initial view.

Creating a lookAt

This is the position that we will look at, and will be associated with a placemark.
Note that the range and tilt have been supplied as part of the control framework

Creating a placemark and using a custom icon

Each spot in our input data will get a marker placed on google earth. Each placemark is associated with a ‘lookAt’. I also provide the capability to change the marker to a link specified in the input data.
The marker image is specified in the spots framework
Venue Photo refers to an entry in the VizMap Dictionary that will be used as the marker.

Putting all that together

Each spot in the input data needs a placemark and a lookAt

Viewing the LookAt

The final step is to view the lookAt.

Marker click event

When one of my markers is clicked I bring up a tabbed infowindow. Tabbed infowindows are not supported directly by Google Maps V3. See Creating a tabbed Google Mapping InfoWindow for how to do this.
However, I also added a doubleclick event that caused me many problems. So much so I decided to create a sectino all of its own, see Click events in Google Earth

Creating a balloon

In the case of both Maps and Earth, it is possible to assign a div element to the content of a balloon or infoWindow. It is this capability that has allowed this application to embed controls, visualizations and other content in these info windows. Earth is simpler than Maps, in that we don’t need to deal with the domready event.

Deleting a balloon

In Maps, closing an infowindow deletes it. This is an action performed on the infoWindow. For Earth you use an instance level method – setBaloon(null)

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

For help and more information join our forum, follow the blog, follow me on Twitter