ElevationRamp to Polyline

1. A concise explanation of the problem you're experiencing.

Is it possible to apply ElevationRamp to Polyline?

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

        var dataSourcePromise = Cesium.GeoJsonDataSource.load('rohace.geojson', {});
        function getColorRamp() {
            var ramp = document.createElement('canvas');
            ramp.width = 100;
            ramp.height = 1;
            var ctx = ramp.getContext('2d');
            var values = [0.0, 0.045, 0.1, 0.15, 0.37, 0.54, 1.0];
            var grd = ctx.createLinearGradient(0, 0, 100, 0);
            grd.addColorStop(values[0], '#000000'); //black
            grd.addColorStop(values[1], '#2747E0'); //blue
            grd.addColorStop(values[2], '#D33B7D'); //pink
            grd.addColorStop(values[3], '#D33038'); //red
            grd.addColorStop(values[4], '#FF9742'); //orange
            grd.addColorStop(values[5], '#ffd700'); //yellow
            grd.addColorStop(values[6], '#ffffff'); //white
            ctx.fillStyle = grd;
            ctx.fillRect(0, 0, 100, 1);
            return ramp;
        var material1 = new Cesium.Material.fromType('ElevationRamp');
        shadingUniforms = material1.uniforms;
        shadingUniforms.minHeight = -414;
        shadingUniforms.maxHeight = 8777;
        shadingUniforms.image = getColorRamp();
            viewer.dataSources.get(0).entities.values.forEach(function(entity) {
                if (entity.polyline) {
                    entity.polyline.material = material1;

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I want to draw polyline (from geojson) and color it based on elevation. I tried creating material from ElevationRamp as seen here https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Globe%20Materials.html but it doesn't work. Either I'm missing something or it just doesn't work for polyline.

4. The Cesium version you're using, your operating system and browser.

Cesium 1.52, Chromium 70, Linux

Yeah unfortunately, as you’ve discovered, the Elevation Ramp is a globe material, and can’t be applied to other types of geometry (more on why that is in this post).

You might need to write a custom material/appearance for your line. This might be a good place to start:

If you get it working please post a code snippet here! I don’t think we have any examples of a custom appearance on a polyline off the top of my head on our docs, so it would be a useful reference.

hi , have you solve this problem?

No I haven’t. I abondoned this task for now.