openlayers icon indicating copy to clipboard operation
openlayers copied to clipboard

layerState is undefined in inView function

Open haluvibe opened this issue 1 year ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

In this file: src/ol/layer/Layer.js

It can be that layerState is undefined in the inView function.

This causes an error at this line

export function inView(layerState, viewState) { if (!layerState.visible) { <---------- here is the line causing the error because layerState can be undefined which throws an error

To Reproduce Steps to reproduce the behavior:

  1. Go to https://maps.nhvr.gov.au/?networkLayerContext=NATIONAL_MAP&view=Category
  2. Click on select a network and select some segments and open the console.
  3. See error

Expected behavior A clear and concise description of what you expected to happen.

Will error out because layerState is potentially undefined. Extremely simple to fix, just change it to:

src/ol/layer/Layer.js export function inView(layerState, viewState) { if (!layerState || !layerState.visible) {

This works without causing any unwanted side effects.

haluvibe avatar Jun 14 '24 02:06 haluvibe