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

Dynamic background color change doesn't work #14894

Closed
kikuchan opened this issue Jul 12, 2023 · 1 comment · Fixed by #14895
Closed

Dynamic background color change doesn't work #14894

kikuchan opened this issue Jul 12, 2023 · 1 comment · Fixed by #14895
Labels

Comments

@kikuchan
Copy link
Contributor

Describe the bug
Dynamic background color change doesn't work as expected for vector layers.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following code
  2. Zoom in/out
  3. You'll see the background color is not changed as expected
import './style.css';
import {Map, View} from 'ol';
import Graticule from 'ol/layer/Graticule';

function background(resolution) {
  const color = resolution < 10000 ? '#88f' : '#f88';
  console.log(resolution, color);
  return color;
}

const map = new Map({
  target: 'map',
  layers: [
    new Graticule({
      background,
    })
  ],
  view: new View({
    center: [0, 0],
    zoom: 0,
  })
});

Expected behavior
The background color is changed when the zoom level (resolution) is changed.

@kikuchan kikuchan added the bug label Jul 12, 2023
kikuchan added a commit to kikuchan/openlayers that referenced this issue Jul 13, 2023
@guisaliba
Copy link

Had this same issue too, thank you for addressing it.

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

Successfully merging a pull request may close this issue.

2 participants