Google Maps Part…..Oh, I Forget - Google Earth

When I started this Google Maps bit, I predicted I would in short order veer off track from my stated outline and start muttering gibberish. I looked back at my posts in this series and I find that assessment to be generally correct, although I think some of the gibberish you may find useful nonetheless. I think it’s time I finished this series of posts, however, before I completely leave the reservation.

To recap, we’ve looked at adding data to Google Maps, converting data to KML, customizing the Google Maps API, and more customizing Google Maps with OpenLayers. Now, let’s take a look at adding data to Google Earth.

First, the good news - Google Earth will take KML, so if you converted your data to KML and you are satisfied with that, you can stop reading now and lead a happy life.

Because that makes for a rather boring post, however, let’s look at what I think is the best way to share your data not only on Google Earth, but also for web sites and desktop clients (WMS and WFS): GeoServer.

From the GeoServer web site (paraphrased):

GeoServer, as the name suggests, is a server. It is open source and it allows users to view and edit geographic data. GeoServer supports WFS-T and WMS open protocols from the OGC to produce JPEG, PNG, SVG, KML/KMZ, GML, PDF, Shapefiles and more.
GeoServer, in a word, is awesome. It can use a number of different data sources, including PostGIS, and serves up your data to any client supporting OGC WMS and WFS standards. Of important note for us in this instance is the KML/KMZ part - it can serve your data directly to Google Earth in native KML. And it's pretty darn fast.

GeoServer is a Java application and will require a Java JDK(I used 1.6) and a servlet engine. One of the download options for GeoServer for Windows comes with Jetty if you want to install and play around with it, but you’ll likely want a servlet engine with a little more meat on it in production. You can download the WAR file and install it through Tomcat without a problem (I used Tomcat 6).

Getting it configured for your data isn’t exactly the easiest thing in the world. To get a layer of your own up and running you’ll need to add a data source, create a namespace (optional), then create a feature type, and then (likely) create a SLD style, which is an OGC standard XML format for styling layers. Phew!

Once you’ve done that, however, you’re good to go. While I didn’t like the whole SLD bit at first, it is really useful to have the styling associated with the layer at the server end. You can push down some general mapping standards that way, and you can have alternate SLD’s for each layer should more than one rendering be necessary. It takes the need to mess with styling completely out of a developer’s hair.

Now let’s take a look at some GeoServer layers in Google Earth. Presuming you have Google Earth installed, each of these links should prompt you to open them in Google Earth:

Polling Locations

The polling locations are polling locations in Mecklenburg County. They are little purple dots that are quite challenging to see. I like to challenge people when they view my maps. Keeps one young and all of that. They are also, however, a bit boring.

The second one is an example that comes with GeoServer. It shows the states in a much less challenging color format, and they also show a custom placemark template. If you click on one of the state markers, you get the tabular information displayed in a pop-up. This is a capability added to GeoServer 1.5.1.

Viola - your data repository shared out to Google Earth. And to your web sites and desktop clients. All from one place, no data conversions necessary. Because GeoServer supports WFS-T, clients can also edit the data. As I said, GeoServer is awesome, and I highly recommend it. I’m working on a project using GeoServer and OpenLayers right now that I’m planning on releasing the code for. If I can get some quality work done on it next month, I’ll blog about it.

That wraps my Google Earth tutorial posts. I hope you found them useful!

*One side note - if you have ArcMap, there’s an easier way to create your SLD’s. ArcMap2SLD Converter will take the rendering from your open ArcMap document and convert it to a SLD file. It doesn’t seem to support attribute labeling and I can’t seem to convince it that I don’t sprache wählen, but it does a great job taking care of the bulk of the work. Google’s Summer of Code has a project going for a SLD author for GeoServer, so hopefully it will turn out something useful that doesn’t require an ArcView license.