Adding WMS overlays to Google Earth



1. Access to a WMS server that can output WGS84 coords (EPSG 4326) .. if you’re unsure, take a look at the capabilities
2. A well set up WMS with view scales (otherwise some retrievals will take a while)

To give a bit of background on how the following code works, Google Earth has the ability to send the bounding box coordinates of your current view to a file, or webpage. Now, for those people whose light bulbs arent going off, this means it is quite easy to create a small bit of code to capture these bbox coordinates and transform them into a WMS request. The WMS output can then be overlaid quite accurately with GE’s sat imagery and tilted, zoomed to your hearts content.

Just before i post the code, please note that i have added additional IP checking functionality to limit who can connect to your WMS reflector script. To add / remove access, simply edit the if ($match[1] line to modify the ip address range. Alternatively feel free to just strip out the ip checking code altogether. Personally, theres nothing worse than someone posting the link and bringing your server to a crawl but to each their own i guess.


PHP Source (Very simple, no ip checking).

  • This also contains the fix to keep the correct aspect ratio so the images overlay correctly.
  • If you require a mechanism to only switch on layers at certain scales, use the code in this entry.

Id suggest adding the network link using the “When camera stops” refresh option, and set it to a minimum of 4 sec wait time. You should be able to see the following neat folder structure as seen below,


Any questions or comments, please leave a comment. It will be interesting to see how well Geoserver 1.3 handles its native KML output.