Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVTLayer requires documention #207

Open
JannikGM opened this issue Aug 11, 2021 · 4 comments
Open

MVTLayer requires documention #207

JannikGM opened this issue Aug 11, 2021 · 4 comments

Comments

@JannikGM
Copy link
Contributor

It requires template parameters, but it's unclear what should be used. I ended up using as any on the props, too.
I think there should be more samples and documentation to make this easier to understand.

@mz8i
Copy link

mz8i commented Sep 27, 2021

I am also looking into how to avoid using as any here.
For example, when using the default renderSubLayers (which defaults to GeoJsonLayer), my approach for adding GeoJson-specific styling props would be to write

interface DataType {}
new MVTLayer<DataType, MVTLayerProps<DataType> & GeoJsonLayerProps<DataType>>({
   //... add a getLineColor prop here
})

However, that still results in a type error, for example

Object literal may only specify known properties, and 'getLineColor' does not exist in type 'TileLayerProps<any>'

Looking at the type definitions, I am wondering if there is a mistake in https://github.com/danmarshall/deckgl-typings/blob/master/deck.gl__geo-layers/index.d.ts#L247 - shouldn't the constructor arguments read ...props: P[] ? @danmarshall
Changing that line locally seems to enable that kind of usage, but I don't know the whole set-up well enough to understand if it will cause any problems.

@mz8i
Copy link

mz8i commented Sep 27, 2021

On further checking, this doesn't really work as then you can pass anything for the props. Perhaps TileLayerProps needs to have an additional generic parameter for the sub-layer properties?

@danmarshall
Copy link
Owner

Might be helpful if someone can provide sample code of what the desired behavior should be, then we can work backwards to see how to make the typings enable that.

@kopp
Copy link

kopp commented Nov 19, 2021

I might jump in to give @danmarshall a usage example.
I would like to be able to iterate over different kinds of data and provide one MVTLayer per kind.
The properties for how to display a particular kind should be stored in a Map:

const propertyFor = new Map<string, any>([
  [
    "rivers",
    {
      getLineColor: [0, 0, 192],
    },
  ],
  [
    "streets",
    {
      getLineColor: [80, 80, 80],
    },
  ],
]);

and then I like to loop over my kinds and create the layers:

for (const kind of ["rivers", "streets"]) {
  layers.push(new MVTLayer({
    id: kind,
    data: dataFor.get(kind),
    ...propertyFor.get(kind),
  });
}

The value type in the Map should now be something like MVTLayerProps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants