Duplicate placemarks appearing in Google Earth

1,732 views
Skip to first unread message

sbkrogers

unread,
Feb 26, 2007, 2:10:34 PM2/26/07
to KML Discussions
I have the following situation:

I have a set of placemarks that I want my users to see in Google Earth. These placemarks will always be seen (e.g. they will always be in the KML file). I am going to dynamically generate the KML for Google Earth via a database. On our website, I want to have several links to the KML file on different pages, and when someone clicks on a link I want the user to be sent to a different location in the KML file based on what link they clicked on in the wbsite. This isn't an issue, as I can dynamically use the LookAt tag to put people at the correct location based on where they are in the site.

However, I run into issues when people leave Google Earth running, and then come back to the website. if they click on another link to download the KML, the user is getting duplicate placemarks in Google Earth (e.g. they see it twice). It would appear that Google Earth is seeing the two links as two separate KML documents. If i click on a third link, they get three placemarks, etc.

Is there are work-around for this, or an alternate approach?

Forkboy2

unread,
Feb 26, 2007, 2:59:42 PM2/26/07
to KML Discussions
Sounds like you are basically loading the same KML file multiple times and they stay in the Temporary Places list.

I think you might have to have them download the main KML file with all the data and then at other places on your website just have them download a KML that doesn't contain the data, but only moves the location.

Maybe someone else will have a better solution.

ManoM

unread,
Feb 26, 2007, 4:08:08 PM2/26/07
to KML Discussions
Hi sbkrogers,

This is just a quick thought, let me know if you want more elaboration:

You could use some combination of <cookie>, <Update>, and <flyTo> to track which links have been clicked. It would require some server side scripting and state-tracking, but probably not too difficult.

ManoM

sbkrogers

unread,
Feb 26, 2007, 5:40:20 PM2/26/07
to KML Discussions
Hi ManoM:
I can see parts of how to implement the solution you're describing but I'm having a hard time pulling the pieces together. Would you mind elaborating?

thanks for the quick reply.

ManoM

unread,
Feb 26, 2007, 7:38:08 PM2/26/07
to KML Discussions
Hi sbkrogers,

Let me make sure I understand what you're looking for. You have a site that has multiple places were someone could download a KML file. It is essentially all the same KML file, but with a different LookAt for different links. You want to make sure they don't end up downloading many different versions of the same file.

Here's how I think it could work, though I haven't tried it yet:

1) Assign the user an html cookie, which identifies them to the site, and have the site keep track of the current page they user is on.

2) Have the KML that the user downloads generated by a script (in PHP, Python, Java, whatever)

3) When the user clicks on a link, it points to a that script checks the cookie sees if that user has downloaded a file before. If not, it gives them a NetworkLink that points to the script.

4) The next time the user clicks on a link, on a different page, the script checks the cookie, and sees they've downloaded already. So instead it passes the request to a NetworkLinkControl that uses Update to Change the LookAt for the file.

ManoM

sbkrogers

unread,
Feb 27, 2007, 7:51:48 AM2/27/07
to KML Discussions
>From my tests, it doesn't appear that i can change the LookAt node in the document. For an initial LookAt, i have the below:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<LookAt id="la123">
<longitude>-105.44</longitude>
<latitude>40.42</latitude>
<range>100</range>
</LookAt>
...rest of document...

In the update node, i have the below:
<Change>
<LookAt targetId="la123">
<longitude>140.42</longitude>
<latitude>-95.43</latitude>
<range>200</range>
</LookAt>
</Change>

Upon loading the update document my location isnt changed. I have flyToView set to "1" in both documents:
<flyToView>1</flyToView>

The other issue that I'm going to run into is that I won't be sure that someone has downloaded the document. e.g. they MIGHT have the KML file already open (in which case an update would work great), or they might open the file (in which case we would set the cookie) then they close Google Earth. the cookie would still be set, but GoogleEarth would be closed (in which case I would not know to send them the full document).

ManoM

unread,
Feb 28, 2007, 12:13:22 PM2/28/07
to KML Discussions
Hi sbkrogers,

Do you have flyToView set to 1 on the <NetworkLink>?

The second problem is a definite problem. You might be able to do something with the <cookie> in the <NetworkLinkControl>, or work with expiring the <NetworkLink>.

ManoM
Reply all
Reply to author
Forward
0 new messages