Introduction and Yahoo! Pipes

Thursday, May 03, 2007 at 11:27:00 AM

I wanted to introduce myself. Like Pamela Fox and Chris Schalk, I work on the Geo API Team. My focus has been on helping people with KML. Traditionally, this meant working with Google Earth, but increasingly KML is being used in a variety of applications, from Maps, the Maps API, Google Maps for Mobile, and My Maps. Google is also making KML content available through KML Search in Earth and Maps. It's an exciting world, and I often say that I have the best job at Google. If you want more help with KML, check out the KML Support group in Google Groups.

Now for the announcement. Yahoo! Pipes now allows output as KML. "Pipes is an interactive feed aggregator and manipulator." Pipes allows you to take feeds from a variety of sources, mash them all together, and create your of custom feed out of them. And now, you can push that content out using KML, even if the original content was not in KML. Consumers of your feed will be able to either click on a link and download KML, or point the Maps API or a NetworkLink directly at the feed. Pipes already accepts KML as an input as they accept any XML files.

For example, Kiva Loans by Location is a Pipe that takes a listing of open microloans on Kiva.org and geocodes each item based on the nationality of the entrepreneur requesting a loan. It's possible to use the KML output of this Pipe in a variety of ways including exploring it in Google Earth and plotting it on Google Maps using the maps API, like this example:


To get the KML output of any Pipes feed, add &_render=kml to the end of the URL. That produces KML that you can use in a NetworkLink or directly in the Maps API. In a NetworkLink, put it in the element:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
  <NetworkLink>
    <name>Yahoo! Pipes Example</name>
    <Link>
      <href>http://pipes.yahoo.com/pipes/pipe.run?_id=AjnnIana2xG7EedQYEsBXw&amp;_render=kml</href>
    </Link>
  </NetworkLink>
</kml>
There are two things to be careful of, when loading data into Google Earth. First, Pipes adds TimeStamps by default to the KML output, which might mean that if your time slider isn't fully expanded, you won't see all the points. Second, the "&" in the URL that points to the KML file will have to be escaped. I highlighted that in bold in the example above. If you want to use the KML in the Maps API, just load it using GGeoXML. The code for the example above is
<script type="text/javascript">
var map;
var geoXml;

function load() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    geoXml = new GGeoXml("http://pipes.yahoo.com/pipes/pipe.run?_id=MGYBl4H52xGXVIf6y6ky6g&_render=kml");
    map.setCenter(new GLatLng(0,0), 1);
    map.addOverlay(geoXml);
  }
</script>