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

Add option to set main button with a Unicode Decimal Code #241

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

eldk
Copy link

@eldk eldk commented Nov 9, 2019

Hello,

As I want to keep main ol-layerswitcher button as OL buttons style :

1 - I have to change background color for ol-layerswitcher main button
2 - I have to remove background-image only for ol-layerswitcher main button, not for the underneath panel.
3 - I have to replace background image with a simple character , I have choosen this for the moment.

So I have done those things :

  • create a CSS class for ol-layerswitcher main button, this way, color and background-image may be set without interfering with underneath panel.
  • add an option to ol-layerswitcher control to gives the unicode decimal value of the desired character. If option buttonUDCChar is not set or no character is given then it fallback on actual CSS background-image.

In your inline CSS - disable background image and set color to OL controls button standard:

button.layer-switcher-open-main {
  background-image: none !important; //removed only for main button
  background-color: rgba(0, 60, 136, 0.5) !important; // color set only for main button
}

Gives optional character when create the LayerSwitcher :

var mLayerSwitcher = new LayerSwitcher({
                tipLabel: 'Légende', 
                buttonUDCChar: '9776' // hamburger UDC value
            })

maybe this may help someone.

Thanks,

Eric

PS : I have also add type to main button (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Button)

localhost_1234_(Galaxy S5)

localhost_1234_(Galaxy S5) (1)

eldk added 5 commits November 9, 2019 23:33
- add type to main button (https://developer.mozilla.org/fr/docs/Web/HTML/Element/Button)
- add a CSS class selector for main button
- add option to use a character in place of CSS background image. Unicode Decimal Code.

The goal is to follow the OL default CSS for controls buttons.

In your inline CSS - disable background image and set color to OL controls button standard:

button.layer-switcher-open-main {
  background-image: none !important;
  background-color: rgba(0, 60, 136, 0.5) !important;
}
@walkermatt
Copy link
Owner

Hi @eldk how about using SVG as the background (which shouldn't require any changes to ol-layerswitcher) https://stackoverflow.com/a/25593531/526860

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

Successfully merging this pull request may close these issues.

2 participants