earthoutreach / earth-api-utility-library

Automatically exported from code.google.com/p/earth-api-utility-library
0 stars 0 forks source link

JS for addPointPlacemark #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Here is a link to the original thread:
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/
40f5887ec5c2f98f

I would like to request that gex.dom.addPointPlacemark(point, {
description: xxx }) be able to handle JS for click handlers to allow events
with balloons. I am not sure if I got the terminology correct, but
basically what I am trying to do is recreate the "JavaScript in Balloons"
example shown in the Google Earth API code playground but instead using
Google Earth Extensions.

Original Message:
(Bahador wrote)
I would like to suggest that gex.dom.addPointPlacemark({ description:
xxx }) support onload when passed with an image tag.

TLDR: I am tring to recreate the "JavaScript in Ballons" example shown
in the AJAX APIs playgound (http://code.google.com/apis/ajax/
playground/?exp=earth#javascript_in_balloons) but instead using gex
(http://code.google.com/p/earth-api-utility-library/)

Here is a link to an example page I have created without using gex.
http://bioseed.mcs.anl.gov/~nosrat/FIG/metagenomics.cgi?page=Example
I would like to recreate this using gex, but all my attempts fail.

Here is the following piece of code that I am trying to pass to the
description key in addPointPlacemark using gex:

// start code
html = '<div id="popup_window"></div><img src="./Html/clear.gif"
onload="execute_ajax(\'display_content\', \'popup_window\',
\'metagenome_id=METAGENOMEID\');"/>';

gex.dom.addPointPlacemark( [lat, lon], { name: 'name', description:
html });
// end code

But when I look at firebug, the div is correct, and the img src is
correct, but there is no onload. It looks like this:

<div style="margin: 0px; padding: 0px; position: absolute; top: 0px;
left: 0px; font-size: small;">
<h3>name</h3>
<div id="popup_window"/>
<img src="./Html/clear.gif"/>    <--- onload should be in here

Here is an example of a gex implementation trying to plot only a since
placemark using the onload:

http://bioseed.mcs.anl.gov/~nosrat/FIG/metagenomics.cgi?page=gex2

Thanks for your time 

(Roman N wrote)
Hi bahador,

Since description: html just uses placemark.setDescription(html),
which filters balloon contents for JS, IFRAMEs, etc., you'll still
need to use a custom click handler to get your JavaScript working,
i.e.:

  var placemark = gex.dom.addPointPlacemark(...);

  google.earth.addEventListener(placemark, 'click', function(event) {
    event.preventDefault();

    var balloon = ge.createHtmlStringBalloon('');
    balloon.setFeature(event.getTarget());
    balloon.setContentString(event.getTarget().getDescription());
    ge.setBalloon(balloon);
  });

Though this would be a good feature request for GEarthExtensions, to
allow something like this:

gex.dom.addPointPlacemark(point, {
  name: 'Foo',
  description: 'Blah',
  unfilteredBalloons: true

});

and safeBalloons (naming TBD) would effectively create a custom event
handler that would result in unfiltered balloons.

If you think that'd be a good feature, can you file it in earth-api-
utility-library?

Thanks!
Roman 

Original issue reported on code.google.com by bahador....@gmail.com on 23 Jun 2009 at 2:14

GoogleCodeExporter commented 8 years ago

Original comment by api.roman.public@gmail.com on 24 Jul 2009 at 11:03

GoogleCodeExporter commented 8 years ago
Note that a simple implementation calling

    balloon.setContentString(event.getTarget().getDescription());

would not take BalloonStyle and entity replacements into account. Just a 
note--I'll
still implement this at some point.

Original comment by api.roman.public@gmail.com on 9 Aug 2009 at 8:16