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

color function arguments vary by geometry type #152

Open
collord opened this issue May 28, 2024 · 1 comment
Open

color function arguments vary by geometry type #152

collord opened this issue May 28, 2024 · 1 comment

Comments

@collord
Copy link

collord commented May 28, 2024

According to the documentation in Readme.md and what I have seen debugging, the two arguments for the color function vary by geometry type. As someone who wants to color a bunch of points by e.g. feature.properties.my_value, I'm totally confused. Is this an error or intentional?

"shapes" (i.e. polys) and lines:
When color is a Function its arguments are the index:number and the feature:object that is being colored

points:
When color is a Function its arguments are the index:number and the point:array that is being colored

Thanks!

@hhalaby
Copy link

hhalaby commented Jun 25, 2024

The discrepancy is quite confusing. If you look at points.ts:

  • When plotting an array the color function takes in LatLng
  • When plotting a FeatureCollection the color function takes in the entire feature.

Is there a reason for implementing it like this ?
Same thing happens for the size property and I think it would be better if both color and size take in the entire feature

if (colorFn) {
          chosenColor = colorFn(i, latLng);
        }
if (colorFn) {
                    chosenColor = colorFn(i, feature);
                }

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