Using GeoWebCache with Google Earth
Google Earth uses tiling and a format called KML. It can be used in two ways:
- Hierarchies of raster tiles, where the data is in PNG or JPEG format. These should work against any WMS server, the tiles are requested in EPSG:4326.
- Output vector data directly in KML, optionaly in a hierachical manner. This requires the WMS server to support KML and have the ability to regionate information to tiles. It is currently a custom feature only available in GeoServer 1.7.x.
If you go to the dynamically generated list of demo's, the first bullet point above corresponds to the KML (PNG) column, and the second one corresponds to KML (Vector). Most users will just want to copy the link from the demo page and share that.
Sample links to hierarchies:
- http://yourserver:8080/geowebcache/service/kml/topp:states.png.kml
- http://yourserver:8080/geowebcache/service/kml/topp:states.jpeg.kml
- http://yourserver:8080/geowebcache/service/kml/topp:states.kml.kmz
The name of the layer is in all cases topp:states, whereas the first extension signifies the underlying format. The second extension can either be .kml or .kmz, the latter being an archive format which essentially zips files together for better performance. This generally only makes sense if you are serving vector KML.
Each of the links above lead to a so-called superoverlay, a KML file which only contains a minimal description and a link to the rest of the hierarchy.
Custom Superoverlays
If you wish, you can skip these superoverlays to add a better description or tweak paramters. It is recommended that you download one of the superoverlays above and use it as your template, as well as find the link to the top tile in the hierarchy. For example, if the first tile is the entire western hemissphere, as it is for topp:states, the first tile is
<href>http://yourserver.com:8080/geowebcache/service/kml/topp:states/x0y0z0.png.kml</href>
Alternatively, if you prefer JPEG, <href>http://yourserver.com:8080/geowebcache/service/kml/topp:states/x0y0z0.jpeg.kml</href>
Note that for data spanning the entire globe there will be two hierarchies, and two links.
Beyond this, you can use the following XML code as a template.
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Folder>
<NetworkLink>
<name>SuperOverlay:TITLE_OF_LAYER</name>
<Region>
<Lod>
<minLodPixels>128</minLodPixels>
<maxLodPixels>-1</maxLodPixels>
</Lod>
</Region>
<Link>
<href>http://EXAMPLE.COM:PORT/GEOWEBCACHE_PATH/kml/YOUR_LAYER/x0y0z0.kml</href>
<viewRefreshMode>onRegion</viewRefreshMode>
</Link>
</NetworkLink>
<LookAt id="superoverlay">
<longitude>-96</longitude>
<latitude>39</latitude>
<range>6000000</range>
</LookAt>
</Folder>
</kml>
A few notes on the above template:
1.
<name>SuperOverlay:TITLE_OF_LAYER</name>
This will be displayed in the "Places" window. Replace TITLE_OF_LAYER with the name of your layer. This is a title, not code, so exact syntax isn't necessary here.
2.
<href>http://EXAMPLE.COM:PORT/GEOWEBCACHE_PATH/kml/YOUR_LAYER/x0y0z0.kml</href>
This line is where the URL containing the layer served by GeoWebCache is explicitly invoked. Change EXAMPLE.COM:PORT to your website and port number. Change GEOWEBCACHE_PATH to the path of your GeoWebCache instance (Examples: /geowebcache or /geoserver/gwc/service). Change YOUR_LAYER to the name of your layer (Example: topp:states).
For more information on KML syntax, please see the Google KML API documentation.