Skip to content

Allow to pass paint properties when creating a CustomLayer #6412

@Leo-Nicolle

Description

@Leo-Nicolle

User Story

As a developer who wants to create its own layer, let's say that it would draw 3D shapes from a geoJSON, I would like to be able to provide the same paint and API as the official maplibre layers for instance:

const myCustomLayer = myLayerFactory({
  id: "custom-layer",
  type: "layer-type",
  source: "my-source",
    paint: {
      "some-property": [
         "match",
         ["get", "building_type"],
         "residential",
         "#f00",
         "commercial",
         "#0f0",
         "#000"
      ]
  }
});

And to benefit from the full power of the Styles Spec.

When I add my CustomLayer to the map, it goes through there, passing nothing to the StyleLayer constructor for the properties params, resulting into my layer having no Transitionable (early return in the constructor + no properties params)

Rationale

  • Why is this feature needed?
    To make maplibre easily extendable with custom layers, and make the whole ecosystem use the same API.

  • What are some example use cases?
    Any custom rendering of a geoJSON.

  • Can it be done today? Is there a workaround?
    That's my question, maybe there is?

Impact

Well it would benefit for anyone developing custom layers, and any programmers using them.

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions