-
Notifications
You must be signed in to change notification settings - Fork 1
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
How to assign random colors to the shapefiles, geojsons, kml features using colorbrewer #41
Comments
@Ghetz Hi, I am not sure it's related to this library and I am not sure I understand the question. |
@aviklai Thanks for your prompt response. No, it's not related to your library. I'm basically trying to randomly assign different colors to the features. No worries, I will played around with the code a bit and see how it goes. Many thanks once again for your awesome code. |
@aviklai, Hi, I'm still struggling to assign different colours to each GeoJSON feature instead of the default blue colour. For example, if a file of US states is loaded, I want each state to have a different color. I tried creating a codesandbox of your code to show you but it fails to run, though it runs in the webpack dev server on my PC. Please I need your advise as to which file(s) in your code should be modified to change the default blue colour of the features in the map. For example in App.tsx, I tried: // a function to set colours
But it doesn't work. |
@Ghetz check this out: |
@aviklai , thanks so much
and
I have just seen your awesome codesandbox which will be a very helpful guide to get everything working. Lastly, how do I retrieve the imported layers names please? |
No worries, I will try and work the imported layers names out. |
Thanks Aviklai, for your cool code.
I'm new to react-leaflet and need some direction on how to assign random colors to the features similar to https://github.com/oxy86/react-leaflet-maps-shapefile
I tried the following (which may be the wrong approach) by adding style:
import colorbrewer from
'colorbrewer';`export default class GeoData { public zoom: number; public center: any; public style: any;
}`
But the colorbrewer import is throwing up [Cannot find module or its corresponding type declarations ...] error which I should be able to fix.
More importantly, I want to know whether the above is the right approach.
Any help will be very much appreciated.
The text was updated successfully, but these errors were encountered: