Jonathan Gamble
unread,Dec 10, 2009, 9:56:52 PM12/10/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KML Developer Support - Advanced Support for KML
I'm trying to create a balloon from from information on just one kml
layer while the other layers are shown...
// the add and remove kml functions
function addObject(object) {
ge.getFeatures().appendChild(object);
}
function removeObject (object) {
ge.getFeatures().removeChild(object);
}
// define the kml objects
var red, wells, green, yellow;
// fetch the KML
var url = 'yellow.kml';
google.earth.fetchKml(ge, url, function(kmlObject) {
yellow = kmlObject;
addObject(kmlObject);
});
// fetch the KML
var url = red.kml';
google.earth.fetchKml(ge, url, function(kmlObject) {
red = kmlObject;
addObject(kmlObject);
});
// fetch the KML
var url = 'wells.kml';
google.earth.fetchKml(ge, url, function(kmlObject) {
wells = kmlObject;
addObject(kmlObject);
});
// fetch the KML
var url = 'green.kml';
google.earth.fetchKml(ge, url, function(kmlObject) {
green = kmlObject;
addObject(kmlObject);
});
google.earth.addEventListener(ge.getGlobe(), 'click', function
(event) {
removeObject(green);
removeObject(yellow);
removeObject(wells);
// prevent the default balloon from popping up
event.preventDefault();
var KMLData;
if (event.getTarget().getType() == 'KmlPlacemark') {
KMLData = event.getTarget().getName();
// create the balloon
var balloon = ge.createHtmlStringBalloon('');
balloon.setFeature(event.getTarget());
balloon.setMaxWidth(450);
// print the balloon
balloon.setContentString(KMLData);
ge.setBalloon(balloon);
}
addObject(green);
addObject(yellow);
addObject(wells);
});
});
}
The problem is that the code still gets data from all 4 layers
depending on where you click. Is it possible to just get information
(the getName() function) from just one layer regardless of whether or
not the other layers are visible?
Thanks,
- Jonathan