Relative URLs in Links

758 views
Skip to first unread message

bsdz

unread,
Aug 10, 2009, 12:02:57 PM8/10/09
to KML Developer Support - Getting Started with KML
Hi

I have several KML files that have network links that look something
like the following and they work fine. This example would be found at
http://www.mydomain.com/main.kml.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<name>My KML View</name>
...

<NetworkLink>
<name>My Subview One</name>
...
<Link>
<href>http://www.mydomain.com/cgi/subview1.py</href>
...
</Link>
</NetworkLink>

...
</Folder>
</kml>

I now would like to transfer these files to a different server with a
different domain, i.e. www.myotherdomain.com. I would like to replace
the above <href> element with a relative path as described in the KML
reference; something like: -

...
<href>/cgi/subview1.py</href>
...

This does not seem to work. GE doesn't seem to pick up the base URL in
http://www.myotherdomain.com/main.kml and prefix the Link's <href>.

Does anyone have any pointers or suggestions short of recreating my
main.kml for each server I wish to deploy to?

Thanks in advance
Blair

treebles

unread,
Aug 10, 2009, 1:18:16 PM8/10/09
to KML Developer Support - Getting Started with KML
You state that your link looks like

<href>/cgi/subview1.py</href>

not sure how the kml parser works but in Unix if you start your path
with a / it means that the path is relative to the system's root
directory.
The kml reference guide states that the relative path is relative to
the location of the KML file.
If your KML file is in the same folder as the cgi directory then you
should use

<href>cgi/subview1.py</href>

If this is not the case then you need to provide more information.

On Aug 10, 12:02 pm, bsdz wrote:
> Hi
>
> I have several KML files that have network links that look something
> like the following and they work fine. This example would be found athttp://www.mydomain.com/main.kml.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://www.opengis.net/kml/2.2">
>   <Folder>
>     <name>My KML View</name>
>     ...
>
>     <NetworkLink>
>       <name>My Subview One</name>
>       ...
>       <Link>
>         <href>http://www.mydomain.com/cgi/subview1.py</href>
>         ...
>       </Link>
>     </NetworkLink>
>
> ...
>   </Folder>
> </kml>
>
> I now would like to transfer these files to a different server with a
> different domain, i.e.www.myotherdomain.com. I would like to replace
> the above <href> element with a relative path as described in the KML
> reference; something like: -
>
>       ...
>         <href>/cgi/subview1.py</href>
>         ...
>
> This does not seem to work. GE doesn't seem to pick up the base URL inhttp://www.myotherdomain.com/main.kmland prefix the Link's <href>.

bsdz

unread,
Aug 10, 2009, 1:26:42 PM8/10/09
to KML Developer Support - Getting Started with KML
Yes, I tried that style path too. I am using GE on Windows and it
looks like it is ignoring the location of my KML file when relative
paths are given in the Link's <href> element. Is there a debug switch
I can turn on that shows GE's HTTP requests?
> > This does not seem to work. GE doesn't seem to pick up the base URL inhttp://www.myotherdomain.com/main.kmlandprefix the Link's <href>.

Barry Hunter

unread,
Aug 10, 2009, 2:05:56 PM8/10/09
to KML Developer Support - Getting Started with KML
The first link that is opened, the file is downloaded by the *browser*
and passed as *content* to Google Earth. Therefore GE doesn't know the
URL location of the original file.

So the very first file needs a full absolute URL to work, but files
loaded via more network links don't.

(you could just make main.kml actully be a python script - it can then
dynamically just insert the host name, so the file copied to the
servers is identical)
> > > This does not seem to work. GE doesn't seem to pick up the base URL inhttp://www.myotherdomain.com/main.kmlandprefixthe Link's <href>.

bsdz

unread,
Aug 10, 2009, 6:08:15 PM8/10/09
to KML Developer Support - Getting Started with KML
Yes, of course. It makes perfect sense now you put it like that. A
generated main file it is then. Thanks.
> > > > This does not seem to work. GE doesn't seem to pick up the base URL inhttp://www.myotherdomain.com/main.kmlandprefixtheLink's <href>.
Reply all
Reply to author
Forward
0 new messages