I am building a geo-visualization application for my dissertation, using google's tools, most notably Google Earth api. I am trying to combine some regions with my placemarks so that i can create different levels of detail, so that some placemarks (larger polygons representing regions) appear when the camera is far enough and other, smaller polygons (representing smaller areas) appear when the camera zooms in (and the larger ones would dissapear).
I know theoreticaly that to achieve this i must enclose the placemarks in regions and set min and max pixels values but my problem starts when i try to create the region itself.
More specificaly, i succeed in creating the region, but an error ocures when i try to append it in a folder. The Error message doesn't help me much because it comes from the init callback function that contains the rest of the code.
"Uncaught Error: Error calling method on NPObject. "
The part of the code that has the problem is the following:
//Try to create region
//experimental
var folder = ge.createFolder('');
var region = ge.createRegion('');
var box = ge.createLatLonAltBox('');
box.setAltBox(<?= $latitude + 0.035 ?>, <?= $latitude - 0.035 ?>, <?= $longitude + 0.035 ?>, <?= $longitude - 0035 ?>, 0.0, 0.0, 0.0, ge.ALTITUDE_CLAMP_TO_GROUND);
region.setLatLonAltBox(box);
var lod = ge.createLod('');
lod.setMinLodPixels(20.0);
region.setLod(lod);
//---------------------
// Create the placemark.
//and add it to the map
var placemark = makeSimplePlacemark(<?= $latitude ?>, <?= $longitude ?>, '<?= $location ?>');
folder.getFeatures().appendChild(region);
folder.getFeatures().appendChild(placemark);
ge.getFeatures().appendChild(folder);
If i remove the line that reads: "folder.getFeatures().appendChild(region);" it works fine, but i need the regions, or another solution perhups. And i am almost sure that the problem is something simple that i am missing... :(
Any help is appreciated. Thank you in advance for your time.