Hi Josh,
Thanks for your reply - unfortunately I am quite busy and not able to
play with it right now.
A couple of quick points though - I have updated the plugin (and the
app - which has caused some problems to be discussed elsewhere) and
the 'balloonopening' event works on your demo page. However, all 3
examples do the same thing - I had to delete the part about the event
listener to get the demo about 'extended data' to work.
Also - the entire 'Get By' examples don't load at all for me?
Anyway, when I get time I will try to implement the 'balloonopening'
event into my site - but could you give me an idea on how to use the
browse the Placemark to extract the ExtendedData for comparison?
ie - I presume something like this will work to a certain degree
google.earth.addEventListener(
ge, 'balloonopening', function(event) {
var placemark = event.getBalloon().getFeature();
var placemark_name = placemark.getName();
if (placemark_name = 'start') {
event.preventDefault();
functionstart();
} else {
if (placemark_name ='stop') {
event.preventDefault();
functionstop();
} else {
// do nothing and let the balloon open
}
});
I am not sure if you can do an IF within an IF like that????
However, it would be best to do what you said and not use the
placemark name, instead use some ExtendedData - so what is the command
to extract that?
something like ?
.....
var placemark = event.getBalloon().getFeature();
var ExtendedDataValue = placemark.ExtendedData('command')
where in the KML the ExtendedData would look like
<ExtendedData>
<Data Name="command">
<value>start</value>
</ExtendedData>
and I could change the <value> to be start/stop/pause/
loadScreenOverlay etc.....
and use the above IF statement to compare the value and choose which
JS function to execute
In your answer you mention having to use fetchKml() on the placemark?
Which I don't understand why (except if that is the way to access the
ExtendedData)
I have read up about the ExtendedData, and it seems like it is fairly
simple to use inside balloons, but I don't see any examples of how to
use it with JS
I am about to finish - and have thought - maybe you mean I need to do
something like
var placemark = event.getBalloon().getFeature();
//not sure on commands for this stuff
fetchKml of the placemark
Walk the Dom to extract ExtendedData
then use an IF statement to compare and decide what to do?
Also, it might be reasonable to just use the placemark_name as I could
make placemarks in the GE tour that are there for no other reason but
to execute some JS.
However, it would be nice to use the ExtendedData, that way I could
remove the 'preventDefault();' and let a balloon open normally while
ALSO executing the JS
Sorry about the long response (especially since I haven't had time to
test my thoughts) - I will be able to test a bit in the next day or
two (at home I have ftp access and time) - I just thought you might be
able to tell me whether I am heading in the right direction or not.
Plus I wanted to acknowledge you for responding to my thread.
Cheers,
Greg
On Jun 19, 2:51 pm, Josh L wrote:
> Hi Greg,
>
> You can get the latest version of the plugin which was launched last
> week (with the new balloonopening event) by uninstalling and
> reinstalling your plugin, or by joining the developer channel (in
> which case you'll be auto-updated to future pre-release versions as
> they become available).
>
> You can see a test of the balloonopening event athttp://
earth-api-dev.appspot.com/#events