In KML, if you want the line to be snapped to the ground, you must set "altitudeModeEnum" to "clampToGround" and archive 1 (true).
<LineString id="myLine">
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
</LineString>
source
share