Skip to content

Unable to use line-gradient paints styles for lines #858

@karlTGA

Description

@karlTGA

mapbox-gl-js version: 0.52
mapbox-gl-draw version: 1.1.1

Steps to Trigger Behavior

  1. Set a line-gradient value in a paint object of a line style.
{
    id     : 'gl-draw-line-static-gradient',
    type   : 'line',
    filter : ['all', ['==', '$type', 'LineString'], ['==', 'mode', 'static']],
    paint  : {
      'line-color'   : 'red',
      'line-width'   : 10,
      'line-gradient': ['interpolate', ['linear'], ['line-progress'], 0, 'blue', 0.1, 'royalblue', 0.3, 'cyan', 0.5, 'lime', 0.7, 'yellow', 1, 'red'],
    },
    layout: {
      'line-cap': 'round',
      'line-join': 'round',
    },
  },

Expected Behavior

Get a nice line with a gradient from green to red.

Actual Behavior

Get an error message:
Error: layers.gl-draw-line-static-gradient.cold: layer "gl-draw-line-static-gradient.cold" specifies a line-gradient, which requires a GeoJSON source with lineMetrics enabled.
at Object.Jr [as emitValidationErrors] (mapbox-gl.js:29)
at De (mapbox-gl.js:33)
at i._validate (mapbox-gl.js:33)
at i.addLayer (mapbox-gl.js:33)
at r.addLayer (mapbox-gl.js:33)
at ctx.options.styles.forEach.style (setup.js:102)
at Array.forEach ()
at Object.addLayers (setup.js:101)
at r.connect (setup.js:35)
at r.ht.fire (mapbox-gl.js:29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI & programatically working with libraryfeature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions