lib/Models/LocationMarkerUtils.js
function correctEntityHeight(
  entity,
  currentCartographicPosition,
  terrainProvider,
  levelHint
) {
  sampleTerrain(terrainProvider, levelHint, [currentCartographicPosition]).then(
    function(updatedPositions) {
      if (updatedPositions[0].height !== undefined) {
        entity.position = Ellipsoid.WGS84.cartographicToCartesian(
          updatedPositions[0]
        );
      } else if (levelHint > 0) {
        correctEntityHeight(
          entity,
          currentCartographicPosition,
          terrainProvider,
          levelHint - 1
        );
      }
    }
  );
}
function correctEntityHeight(
  entity,
  currentCartographicPosition,
  terrainProvider,
  levelHint
) {
  sampleTerrain(terrainProvider, levelHint, [currentCartographicPosition]).then(
    function(updatedPositions) {
      if (updatedPositions[0].height !== undefined) {
        entity.position = Ellipsoid.WGS84.cartographicToCartesian(
          updatedPositions[0]
        );
      } else if (levelHint > 0) {
        correctEntityHeight(
          entity,
          currentCartographicPosition,
          terrainProvider,
          levelHint - 1
        );
      }
    }
  );
}
function correctEntityHeight ( entity , currentCartographicPosition , terrainProvider , levelHint ) { sampleTerrain ( terrainProvider , levelHint , [ currentCartographicPosition ] ) . then ( function ( updatedPositions ) { if ( updatedPositions [ 0 ] . height !== undefined ) { entity . position = Ellipsoid . WGS84 . cartographicToCartesian ( updatedPositions [ 0 ] ) ; } else if ( levelHint > 0 ) { correctEntityHeight ( entity , currentCartographicPosition , terrainProvider , levelHint - 1 ) ; } } ) ; }
Gets the most detailed height from terrainProvider at currentCartographicPosition and updates entity position.
It starts querying at levelHint and makes its way down to level zero.
Gets the most detailed height from terrainProvider at currentCartographicPosition and updates entity position . It starts querying at levelHint and makes its way down to level zero .