Home  >  

Exploring The Google Earth API

Author photo
| | Comments (1)
AddThis Social Bookmark Button

Back in June, Google released the Google Earth API, which is a javascript-enabled browser plugin version of Google Earth. I finally got a chance to explore the Google Earth API, and here's the result.

(Sorry non-Windows users, the Google Earth API only supports Windows)

In my opinion, one of the most interesting things that can be visualized on a map is weather information and radar. The Google Earth api is the perfect medium to render this kind of data, so I figured that was a good place to start. The Google Earth API supports kml rendering, and image overlays. The most complex part of this task is finding the data to display.

This example extends from an older post showing how to layer the Google Earth API and a Flex application. In fact, I haven't even changed a single line of Flex code for this example.

The javascript used to interact with the Google Earth API has been updated so that it overlays a live radar image, and severe weather alerts provided by NOAA.

All of the U.S. weather related information you could possibly imagine is freely available through the National Oceanic and Atmospheric Administration. NOAA has publicly available KML services that allow you to view data directly in the desktop Google Earth application, and a large repository of live radar images for use within GIS applications.

Some of the KML provided by NOAA can actually be directly consumed by the Google Earth API using NetworkLink objects. When Initializing the map through javascript, you can link directly to NOAA's severe weather alert KML service. This service will provide you with live severe weather alerts, with polygonal outlines of the affected areas.

var networkLink = ge.createNetworkLink("");
networkLink.setFlyToView(true);  
var link = ge.createLink("");
link.setHref( "http://radar.weather.gov/ridge/warningzipmaker.php?cachebuster=" + Math.random() );
networkLink.setLink(link);
ge.getFeatures().appendChild(networkLink);


You can find more information about Google Earth networkLink objects at:
http://code.google.com/apis/earth/documentation/introduction.html#network_link

Not all of the NOAA data services can be consumed by the Google Earth API because they must be generated based on a HTTP POST method. The Google Earth API only supports GET. In fact, all of the image-related KML feeds from NOAA require a HTTP POST, and cannot be consumed directly through a network link object. On the other hand, NOAA does provide transparent .gif images that can be used as layers or overlays in GIS applications. These gif images are a perfect case for using groundOverlay objects in the Google Earth API. I decided to use the overlay for the contental US to show live radar.

var groundOverlay = ge.createGroundOverlay('');
groundOverlay.setIcon(ge.createIcon(''))
groundOverlay.getIcon().setHref("http://radar.weather.gov/ridge/Conus/RadarImg/latest_radaronly.gif");
groundOverlay.setLatLonBox(ge.createLatLonBox(''));
	
var center = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var north = 50.406626367301044;
var south = 21.293757;
var east = -66.452507;
var west = -127.620375523875420;
var rotation = 0;
var latLonBox = groundOverlay.getLatLonBox();
latLonBox.setBox(north, south, east, west, rotation);
	
ge.getFeatures().appendChild(groundOverlay);


You can find more information about Google Earth overlays at:
http://code.google.com/apis/earth/documentation/advanced.html#ground_overlay

I completely guessed on the positioning of this overlay. I know that the north and west lat/lon coordinates are correct, b/c they are based on the coordinates provided by NOAA. However the south and east coordinates were guesses based on the size of the image. There is a bit more work involved in getting the exact coordinates, and I didn't have the time to dive in that far.

Hopefully this will provide you with some ideas for your own applications.

You can launch this application in a new window at:
http://www.tricedesigns.com/portfolio/googleearthweather/main.html

View Source:
http://www.tricedesigns.com/portfolio/googleearthweather/srcview/index.html


Related Links:
Previous blog entry
Google Earth API
Google Earth API Examples
Google Maps API
Google Earth Blog

___________________________________
Andrew Trice
Principal Architect
Cynergy Systems
http://www.cynergysystems.com

Read more from Andrew Trice. Andrew Trice's Atom feed

Comments

1 Comments

nancy perez said:

my comment is how can i see pictures where am from.

Leave a comment


Tag Cloud

Poll: Mobile Features

What feature do you use most on your mobile phone?

Vote | View Poll Results | Read Related Blog Entry

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.