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

How to change color of all areas in a row in jquery #418

Open
sophiejarlier opened this issue Nov 25, 2020 · 1 comment
Open

How to change color of all areas in a row in jquery #418

sophiejarlier opened this issue Nov 25, 2020 · 1 comment

Comments

@sophiejarlier
Copy link

Hi,
I am using Mapael map and I would need to change the color of all our areas in a single row..

I know I can change the color of an area as follow:

var updatedOptions = {'areas': {}, 'plots': {}};
updatedOptions.areas["sud-ouest"] = {
	attrs: {
		fill: "#f5821f"
	}
};

But how to change the color of all areas in the same time?
I tried this but it does not work:

updatedOptions.areas = {
	attrs: {
		fill: "#413a32"
	}
};
	

Thanks for your help

@neveldo
Copy link
Owner

neveldo commented Dec 2, 2020

Hello @sophiejarlier , I think the more appropriate way to update the bg color of all the area would be to generate a full JSON object (ie updatedOptions) with the new parameters for all the areas (by looping on all the available areas) and trigger the 'update' event with this object a single time. If you don't want to loop over all the areas and if all the areas share the same bg color, you just have to use map.defaultArea option. This option allows you to define or update the default bg color for all the areas. I hope it will help you !

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