Relative links in KMZ files

1,130 views
Skip to first unread message

Barrett Lawson

unread,
Jan 3, 2012, 11:22:29 AM1/3/12
to kml-support-g...@googlegroups.com
I'm having an issue with relative links inside kmz files.

according to http://support.google.com/earth/bin/answer.py?hl=en&answer=1061393 GE 6 uses the location of the kml file as the base URL and earlier versions looked both there and in the location of the kmz file.
this page http://code.google.com/apis/kml/documentation/kmzarchives.html#externalrefs that covers external refs must be outdated because when I download and open the buffetthawaiitour.kmz file, the overlays do not load.

my kmz file structure
sample.kmz/
    files/
        image.gif
    doc.kml

if I try to make an overlay of image.gif, I use
<Icon>
   <href>files/image.gif</href>
<Icon>

and it appears to look in the folder containing the KMZ file, as if it is the base path.  I'm having the same problem with relative links in description html.

any tips?


SeanA

unread,
Jan 3, 2012, 6:15:36 PM1/3/12
to kml-support-g...@googlegroups.com
Can you post/upload your problematic KMZ somewhere? It's hard to diagnose the problem with just your code snippets.

A couple of comments:

The first document you mentioned (http://support.google.com/earth/bin/answer.py?hl=en&answer=1061393) relates only to the rendering of HTML in pop-up placemark balloons. It specifies how the webkit HTML renderer for the placemark popup balloons will interpret your URLs. So, for an HTML <img src="PATH"> tag the URL base is as described in that document. Base URLs as described there should be strictly enforced.

However, this document *does not* apply to the handling of URL paths in other parts of KML, such as overlays. It will ideally look inside the KMZ for your files (like the above). But if it doesn't find it there, it will also look in the directory where the KMZ file itself is stored. One of the reasons for this is that changing the behavior would break a lot of existing KML. The KML language specification, for better or worse, doesn't yet define what the is base path of a KMZ.

However, the HTML language has pretty strict rules dictating how URLs to images should be specified and what the base path is. By allowing files inside and outside the KMZ to work with the same path, Google Earth was being too lax and violating those rules of the HTML language. That's why we tightened up the definition of the base path for the pop-up balloons. Ideally it would be the same for URLs in the KML (like in overlays), but we don't want to break too many old KML files.

Long story short, for the following directory structure

sample.kmz/
    files/
        image.gif
    doc.kml

In balloon HTML, use:
<img src="files/image.gif" />

In an KML overlay, use*:
<Icon>
   <href>files/image.gif</href>
<Icon>

*Note: that in the KML overlay example above, if there isn't an image inside the KMZ at files/image.gif, it will fetch the image outside the KMZ in the following directory structure:

sample.kmz/
    doc.kml
    *Note, no image in the KMZ.
files/
    image.gif


Along those lines, the Buffet tour works fine for me in Google Earth 6.1. Are they not loading for you?

If you provide your files that aren't working, I might be able to better diagnose your problem.


Barrett Lawson

unread,
Jan 4, 2012, 10:27:40 AM1/4/12
to kml-support-g...@googlegroups.com
The Buffett tour does not work for me:  I don't see any overlays, but I also don't get error messages either.

GE v6.1.0.5001, directx9, win7x64 - same results on both my desktop and laptop.

SeanA

unread,
Jan 5, 2012, 6:25:55 PM1/5/12
to kml-support-g...@googlegroups.com
Hi Barrett,

I am using also using GE v6.1.0.5001, directx9, win7x64 and the tour works fine for me.

Do you have multiple copies of the tour in your My Places? That could cause problems. Could you backup and then delete everything from your My Places and reload the tour to see if it works? Are the two screenoverlays in the Resources/Overlays/ folder under the buffet tour checked on? If they are checked off, it would explain why you aren't seeing it.

The overlays are only supposed to appear twice between 1:05-1:27 and 2:57-3:35.

If you still aren't seeing the overlays, can you load this KML and see if the overlay appears (and slowly fades away after 3 seconds?).

<?xml version="1.0" encoding="UTF-8"?>
  <Document>
    <gx:Tour>
      <name>test tour</name>
      <gx:Playlist>
        <gx:AnimatedUpdate>
          <gx:duration>3</gx:duration>
          <Update>
            <targetHref/>
            <Change>
              <ScreenOverlay targetId="test">
                <color>00ffffff</color>
              </ScreenOverlay>
            </Change>
          </Update>
        </gx:AnimatedUpdate>
        <gx:Wait>
          <gx:duration>3</gx:duration>
        </gx:Wait>
      </gx:Playlist>
    </gx:Tour>
    <ScreenOverlay id="test">
      <name>Maui Tour Overlay</name>
      <color>ffffffff</color>
      <Icon>
      </Icon>
      <overlayXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
      <screenXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
      <size x="0.25" y="0.25" xunits="fraction" yunits="fraction"/>
    </ScreenOverlay>
  </Document>
</kml>
Reply all
Reply to author
Forward
0 new messages