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

highlightColor defined as a function on CartoLayer doesnt seem to work #274

Open
plgagnon2 opened this issue Sep 8, 2021 · 1 comment
Open

Comments

@plgagnon2
Copy link

This doesnt seem to work. But CartoLayer inherit from MVTLayer which inherit from Layer in the end (I think)
https://deck.gl/docs/api-reference/core/layer#highlightcolor

return new CartoLayer({
  ...cartoLayerProps,
  id: id,
  pickable: true,
  autoHighlight: true,
  highlightColor: (info) => {
    console.log('test')
  },
});
@AdriSolid
Copy link
Contributor

AdriSolid commented Sep 23, 2021

Indeed, CartoLayer inherits from MVTLayer.

Did you try to specify uniqueIdProperty? Needed for highlighting a feature split across two or more tiles if no feature id is provided. More info here.

You have to options:

  1. Set it as a CartoLayer prop:
new CartoLayer({
  ...
  uniqueIdProperty: 'your_unique_id_prop',
  autoHighlight: true,
  highlightColor: [0, 0, 255],
});
  1. Set it in your useCartoLayerProps hook like:
const uniqueIdProperty = 'your_unique_id_prop';
const cartoLayerProps = useCartoLayerProps({ source, uniqueIdProperty });

Check CARTO docs for more info here.

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

2 participants