2

I have multiple KMZ files/geoRSS feeds I want to use as different layers in Google Maps (Not Earth).

How would I do this?

I know of two ways to use KMZ files with Maps:

  1. My Maps You can import KMZ files to your heart's content, but the problem with this is that it paginates the results after about 10 items. I want to have both KMZ files displayed, in their entirety, simultaneously. Consequently, this route does not work.
  2. Maps search for KMZ file This groups the entire KMZ file into one layer. Awesome and exactly what I want. However, how do I get this to work with multiple KMZ files?

I can't simply combine the data into one KMZ file because I'm wanting to combine a live geoRSS feed of planning applications with the shape file I link to in point 2.

0

1 Answer 1

4

I think you should be able to do this using a KML file which contains Network Links to your KMZ files.

The nice thing about the Network Links is that it doesn't have to be KMZ files it can be a script or feed that outputs a KMZ/KML file. There is a demo of how to do this here under the section Generating a Random Placemark

Basically you create a KML file in the following format:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Folder>
    <name>Network Links full of awesome</name>
    <visibility>0</visibility>
    <open>0</open>
    <description>Network link example to show how to overlay several KMZ files on one map</description>
    <NetworkLink>
      <name>Earthquakes Mag 7</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 7</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag7.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 6</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 6</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag6.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 5</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 5</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag5.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 4</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 4</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag4.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 3</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 3</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag3.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 2</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 2</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag2.kmz</href>
      </Link>
    </NetworkLink>
        <NetworkLink>
      <name>Earthquakes Mag 1</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>Earthquakes Mag 1</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_Mag1.kmz</href>
      </Link>
    </NetworkLink>
  </Folder>
</kml>

Then in Google Maps, search using the full URL pointing to your KML file and you get something like this:

Google Maps Multiple Overlays

This displays 7 different KMZ files on the same map but using only one URL - the KML file with all the links in.

6
  • That's brilliant, I'll give it a go!
    – aendra
    Feb 1, 2012 at 17:34
  • Fantastic answer, totally worked. Thank you very much! Just one question -- it seems KML doesn't validate if the network link has characters such as ? or & in it, which is problematic for me, given my feed uses GET request arguments (I.e., site.com/feed/?type=stuff&strict=true). Know any way around that? I can't use mod_rewrite, because I'm using ScraperWiki.
    – aendra
    Feb 2, 2012 at 11:22
  • 1
    @aendrew Hmm, can't you off load the processing of the feed to a script file and then link the script file in your <networkLink> element. That way you just point to a script and the script calls the actual URL with the query string parameters. Feb 2, 2012 at 11:41
  • Correction, it's just the & character that muddles up Google Maps. I can pass it a feed with only one argument and it's fine. It stops validating when I add an ampersand. Replacing it with %26 doesn't seem to work; ScraperWiki interprets that as a literal and sees my query string as ?feed=appeals&true instead of ?feed=appeals&strict=true (also truncating my second variable in the process). Any thoughts?
    – aendra
    Feb 2, 2012 at 11:53
  • 1
    Note for anyone coming across this from Google -- if your URL has ampersands in it (I.e., GET arguments), put the URL in <![CDATA[..]]> tags. So, that would look like: <Link><href><![CDATA[http://views.scraperwiki.com/run/hackney_council_planning_and_appeals_rss_output/?feed=appeals&strict=true]]></href></Link> Everything parses fine!
    – aendra
    Feb 8, 2012 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.