-
Notifications
You must be signed in to change notification settings - Fork 87
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
Having trouble adding colors to the map #17
Comments
You need to provide a function to color the points. Here I use Also, I think you need to provide colors in RGB notation. i.e. |
Hi Tim, Thank you for the help. I converted my hexadecimal colors into RGB format and divided by 255, so they look like so:
The data points I have look like this:
Then I followed your example on the link you provided, and now have this:
However, my points are still all coming out grey. Thank you again, |
Are you using the latest version? The index based coloring was only introduced recently. |
Also, I think your color array should be an object and look like this:
At least that's what works for me |
Yes, it worked! Thank you so much. |
Does the documentation need clarified you guys think? |
Also, if hexadecimal is of value, we could easily put in a translator. |
A translator would be great! It would save space for large amounts of data/colors. |
I certainly think that it could be clearer, but I am a total Javascript newbie (about 1.5 months of experience thus far), so that could also explain my troubles. I mainly used the readme.md and the index.html to attempt to solve the problem without success. I've started working on some introductory information for the readme, and I could include info on how to add colors. |
Maybe we could display this part of the points.js file in the readme?
I think it clarifies better what happens when you supply a function to We could also say that if you do supply a function to color, it needs to return a Javascript object of the same length of the data, in the format that Tim specified above, as argument |
So a helper function like: function hexToRgb(hex) {
if (hex[0] === '#') hex = hex.substring(1, 7);
return {
r: parseInt(hex[0] + hex[1], 16),
g: parseInt(hex[2] + hex[3], 16),
b: parseInt(hex[4] + hex[5], 16)
};
}
hexToRgb('#509cd6'); // -> Object { r: 80, g: 156, b: 214 } |
Yes, that looks right! Do we need the spaces in { r: 80, g: 156, b: 214 }? |
it is an object, so... no? |
Then I would vote for dropping them. It may sound ridiculous, but when data grows to 10-20m points, I think those spaces will matter. |
Lets think in terms of what is practical. I'm being too verbose on what would change internally. So supplying something like: |
Yes, that is what we are after |
Hi, thank you very much for this library. I am trying to add colors to my web gl. I have prepared an array of colors the same length as the array of points, with in RGB hexadecimal format.
This is the format:
[["#762181"],["#762181"],["#6E1E81"],["#170F3C"],["#170F3C"],["#420F75"],["#661B80"],["#AE347B"],["#420F75"],["#420F75"]]
I save this as map_colors and call it in L.glify.points as below:
However, the points do not seem to be changing color, they are all grey. Do I need to provide the colors in a different format?
Thank you
The text was updated successfully, but these errors were encountered: