Trigger action from balloon

7 views
Skip to first unread message

tl

unread,
May 26, 2008, 12:07:44 PM5/26/08
to KML Developer Support - KML Server Side Scripting
Hi,

When i click on a placemark, I would like to trigger some web action
scripts.

The first solution i tried is to insert some URL in the balloon so
that when i click on the URL, a php script is started on my web
server : "http://myserver/doaction1.php", "http://myserver/
doaction2.php" etc. If the script generate a web page, the link is
opened in the web navigator and the action is done. The problem for me
with this solution is that i want to avoid to open the navigator

So I am trying to generate KML files from my action scripts. If the
scripts generate a <Document>, then each time the user click on the
related URL, a new document is added in my temporary list, which is
not perfect either. Also if i click several time on the same URL, only
the first click will trigger the script, i guess further don't work
because GE believes it is a static KML file and use his cache

If the scripts generate a <NetworkLinkControl> iso <Document>, i don't
have new entry in temporary list, but still only the first click on
the URL will works.

I finally tried to regularly change the URL in the balloon by
appending a random string to it, but i could not make it works: when i
update the placemark with a NetworkLinkControl/update, the balloon
content does not seem to be refreshed when the placemark description
is changed.

Is there something i missed? Any suggestion would be welcome.

Thierry.

barryhunter [KML Guru]

unread,
May 27, 2008, 8:31:08 AM5/27/08
to KML Developer Support - KML Server Side Scripting


On May 26, 5:07 pm, tl wrote:
> Hi,
>
> When i click on a placemark, I would like to trigger some web action
> scripts.
>
> The first solution i tried is to insert some URL in the balloon so
> that when i click on the URL, a php script is started on my web
> server : "http://myserver/doaction1.php", "http://myserver/
> doaction2.php" etc. If the script generate a web page, the link is
> opened in the web navigator and the action is done. The problem for me
> with this solution is that i want to avoid to open the navigator

You could perhaps make the script return a single pixel image, and
then include the script in a <img> tag? That would register when the
balloon content displays.

Or if you do want to link to another KML, perhaps you could use the
<description>
<![CDATA[
<a href="http://myServer.com/
CraftsFairs.kml#Albuquerque;balloonFlyto">
One of the Best Art Shows in the West</a>
]]>
</description> construct.
http://code.google.com/apis/kml/documentation/kmlreference.html#description

But I feel I dont fully understand your issue. Perhaps you have an
online example you can link to - a picture speaks a thousend words
etc...

>
> So I am trying to generate KML files from my action scripts. If the
> scripts generate a <Document>, then each time the user click on the
> related URL, a new document is added in my temporary list, which is
> not perfect either. Also if i click several time on the same URL, only
> the first click will trigger the script, i guess further don't work
> because GE believes it is a static KML file and use his cache.

You might be able to explictly control that using Cache-Control and
Expires HTTP headers.

>
> If the scripts generate a <NetworkLinkControl> iso <Document>, i don't
> have new entry in temporary list, but still only the first click on
> the URL will works.
>
> I finally tried to regularly change the URL in the balloon by
> appending a random string to it, but i could not make it works: when i
> update the placemark with a NetworkLinkControl/update, the balloon
> content does not seem to be refreshed when the placemark description
> is changed.

Sorry, have no experience with the update mechanism

tl

unread,
May 29, 2008, 5:25:26 AM5/29/08
to KML Developer Support - KML Server Side Scripting
Hi Barry,

Thank you for your answer.

On May 27, 2:31 pm, barryhunter [KML Guru] wrote:
> On May 26, 5:07 pm, tl wrote:
>
> > Hi,
>
> > When i click on a placemark, I would like to trigger some web action
> > scripts.
>
> > The first solution i tried is to insert some URL in the balloon so
> > that when i click on the URL, a php script is started on my web
> > server : "http://myserver/doaction1.php", "http://myserver/
> > doaction2.php" etc. If the script generate a web page, the link is
> > opened in the web navigator and the action is done. The problem for me
> > with this solution is that i want to avoid to open the navigator
>
> You could perhaps make the script return a single pixel image, and
> then include the script in a <img> tag? That would register when the
> balloon content displays.
>
> Or if you do want to link to another KML, perhaps you could use the
> <description>
> <![CDATA[
> <a href="http://myServer.com/
> CraftsFairs.kml#Albuquerque;balloonFlyto">
> One of the Best Art Shows in the West</a>
> ]]>
> </description> construct.http://code.google.com/apis/kml/documentation/kmlreference.html#descr...

Mmm your idea is interesting but i don't necessarily wants my script
to be triggered when the balloon is displayed (but your idea gives
other more possibilities :) ). i have several choices, so i prefer to
represent like a toolbar in the balloon so that we can choose which
script to call.

Anyway, i tried your solution, there is still the same issue: the
script is called only the first time we click on the placemark. On the
second click the image is not reloaded as GE probably has it in a
cache somewhere. So the script is not called a second time.

>
> But I feel I dont fully understand your issue. Perhaps you have an
> online example you can link to - a picture speaks a thousend words
> etc...

So far i am still doing local test.
>
>
>
> > So I am trying to generate KML files from my action scripts. If the
> > scripts generate a <Document>, then each time the user click on the
> > related URL, a new document is added in my temporary list, which is
> > not perfect either. Also if i click several time on the same URL, only
> > the first click will trigger the script, i guess further don't work
> > because GE believes it is a static KML file and use his cache.
>
> You might be able to explictly control that using Cache-Control and
> Expires HTTP headers.

Well if i generate HTML, i add that:
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta http-equiv="EXPIRES" content="-1" />
and it works fine, but i could not find any similar way for KML with a
NetworkLinkControl.

tl

unread,
May 29, 2008, 5:40:36 AM5/29/08
to KML Developer Support - KML Server Side Scripting

Ok for information here is the best solution i think i will be using.

The only way i could find to be sure the server side script will be
called each time, is to use HTML page with meta tag i posted earlier.
I didn't want GE to open a navigator because i already use it on a
page which in my case display some information from my server say
http://myserver/showstatus.php . So i simply make http://myserver/doaction1.php
do the stuff in need then immediately redirect to http://myserver/showstatus.php
so that it looks as transparent as possible.

Of course i have to use internal GE web browser to avoid my navigator
window pup in front of GE each time i click on a balloon.

Thierry.
Reply all
Reply to author
Forward
0 new messages