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

[Question] Is it possible to set legend's text style? #660

Closed
palur76 opened this issue Sep 16, 2021 · 4 comments
Closed

[Question] Is it possible to set legend's text style? #660

palur76 opened this issue Sep 16, 2021 · 4 comments

Comments

@palur76
Copy link

palur76 commented Sep 16, 2021

I'd like to modify the legend's title's text style (eg. add underline), the first item's style (eg. font-style: italic), and all other items style (make them a bit smaller). Is it possible?

Thanks!

@palur76 palur76 changed the title Is it possible to set legend's text style? [Question] Is it possible to set legend's text style? Sep 16, 2021
@palur76
Copy link
Author

palur76 commented Sep 16, 2021

OK, I figured out from the code, that it's not possible. Try to fix it with #662

Viglino added a commit that referenced this issue Sep 21, 2021
@Viglino
Copy link
Owner

Viglino commented Sep 21, 2021

I've added a titleStyle option to let you set the title style (default use the textStyle + bold).

You can also add textStyle to the items themselves to change their fonts one by one:

legend.addItem({ 
  title: 'Car placemark', 
  feature: f0, 
  textStyle: new ol.style.Text({ font: 'bold 13px serif'}) 
});

@roddc
Copy link

roddc commented Dec 16, 2021

@Viglino Hi, how do I display multiple line for the item title, I want to display a long string and I add \n to separate the string, but it only show two line.

@Viglino
Copy link
Owner

Viglino commented Dec 16, 2021

Items are limited to 2 lines.
If you want more, you have to add a new item to the legend...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants