KML Clamp to ground

I know this is an often-asked-for feature, but every post that I can find is 2+ years old, so I'm hoping for some newer information. I'm trying to get some simple KML to display clamped to the ground, using the dragDropMixin. However, the polygons clip with the terrain, and the more I zoom in the worse it gets. Is there support for getting these polygons to properly drape over the terrain? Or does anyone know some alternatives that I can use to get a similar effect? (I have some control over the KML that will be used).

Here's how I set up the viewer:
<code>

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var dragDropOptions = {
  clearOnDrop : true,
  flyToOnDrop : true,
  clampToGround : true
}
             viewer.extend(Cesium.viewerDragDropMixin, dragDropOptions);
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
  url : ‘https://assets.agi.com/stk-terrain/world’,
  requestVertexNormals : true
});

</code>

Here is the KML:
    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Placemark>
        <name>The Empty Box</name>
        <Polygon>
          <extrude>1</extrude>
          <altitudeMode>clampToGround</altitudeMode>
          <outerBoundaryIs>
            <LinearRing>
                <altitudeMode>clampToGround</altitudeMode>

              <coordinates>
                -90.0,30.0,10000
                -90.0,31.0,10000
                -91.0,31.0,10000
                -91.0,30.0,10000
              </coordinates>
            </LinearRing>
          </outerBoundaryIs>
          <innerBoundaryIs>
            <LinearRing>
              <coordinates>
                -90.66,30.33,10000
                -90.33,30.33,10000
                -90.33,30.66,10000
                -90.66,30.66,10000
              </coordinates>
            </LinearRing>
          </innerBoundaryIs>
        </Polygon>
      </Placemark>
    </kml>

And here is an example of what it looks like:

Your coordinates cannot include a Z. You need X-Y coordinate pairs for clampTo Ground to work. Not even a zero, no Z. Your example shows X-Y-Z coordinates. I share your pain, but at least you have control iver the KML, and it's worth the effort to strip out those Z values. You must download the April update being released 4/03! There is an issue being fixed that affects polygons clamped-to-ground when viewed in 2D. But the current release is fine for 3D view.

I tried removing the Z coordinates from the KML, but the behavior didn’t change.

Okay, Nick,
I may have steered you in the wrong direction.

First, if you are using a drag&drop mixin, you’re probably going to need help from another user, or someone on the Cesium team.

I add my KML programatically. My KML is a GPS track,

Also, re-examining my KML files, I did not remove the Z coordinates.

a snippet of my KML:

1clampToGround-71.4316850,44.2103306,852.474

-71.4316850,44.2103306,852.403

-71.4317611,44.2103070,851.827

-71.4318662,44.2102528,852.474

-71.4319812,44.2102064,854.836…

a snippet of my code:

//declared variable at module level: var userKmlFile = wp_plugin_url.concat(“lftgly/datasources/kml/Ski recon.kmz”);

userKmlDataSource = new Cesium.KmlDataSource(“UserKmlData”); //declared variable at module level: var userKmlDataSource;

var options = {camera : CesiumMapViewer.camera, canvas : CesiumMapViewer.scene.canvas, clampToGround : true};

CesiumMapViewer.dataSources.add(userKmlDataSource.load(urlUserKmlFile, options)).then(function(dataSource){

CesiumMapViewer.clock.shouldAnimate = false;

var hiker = dataSource.entities.getById(‘tour’); //"tour’ is the ‘id’ element in the KML, “track” is the ‘name’ element of the same placemark

if (hiker != undefined){

CesiumMapViewer.flyTo(dataSource.entities).then(function(){

CesiumMapViewer.clock.multiplier = 10;

CesiumMapViewer.clock.shouldAnimate = true;			  

}); //end flyTo.then function

}

}); //end load.then function

Removing the Z coordinates was required in my GeoJSON data files for GeoJsonDataSource,

a snippet of my code:

AvalanchePathPolygonsDataSource = new Cesium.GeoJsonDataSource(“AvalanchePathPolygons”);

CesiumMapViewer.dataSources.add(AvalanchePathPolygonsDataSource);

return AvalanchePathPolygonsDataSource.load(jsonFeatureCollection,{clampToGround: true});

I apologize, these two different Cesium datasources behave very differently, thanks for making me review my own code, and good luck to you.

-Jon