Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

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 Go here for an example of this in action. Notice how it groups the entire KMZ file into one layer? This is 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.

Any suggestions you could give me would be awesome. Thanks!

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

You can test this out yourself as I have made the KML file public by using the following link:

http://dl.dropbox.com/u/7257842/ExampleFiles/NetworkLinkFile.kml

share|improve this answer
    
That's brilliant, I'll give it a go! –  aendrew Feb 1 '12 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. –  aendrew Feb 2 '12 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. –  Barry Feb 2 '12 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? –  aendrew Feb 2 '12 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! –  aendrew Feb 8 '12 at 11:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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