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

fix: only issue getlegendgraphic requests for wms layers #1885

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

Grammostola
Copy link
Contributor

Aims to fix #1884

@tonnyandersson
Copy link
Collaborator

tonnyandersson commented Oct 27, 2023

Why not do like below instead of that lonely if statement?

} else {
  content = getTitleWithIcon(title, '');
}

Also, these changes make the changes in PR #1882 a bit redundant. Maybe the whole else if block on lines 244-245 can be removed since those situations will be covered by these changes? Or...?

EDIT 1: Ok, maybe not remove that whole block since there's actually a reason for the else if (!layer.get('type'))... to be there.

EDIT 2: Ok, maybe remove it after all, and add (layer.get('type') &&... to the subsequent else if statements. Makes more sense since the else if (!layer.get('type'))... statement's only purpose is to prevent the execution of the subsequent else if statements and not because typeless layers inherently need special treatment.

EDIT 3: I'm rambling.

@Grammostola
Copy link
Contributor Author

Grammostola commented Oct 27, 2023

I see what you are seeing, the block is a bit of an eyesore.

Something like this might work.. I'll check it on monday.

  const title = layer.get('title') || 'Titel saknas';
  let content = '';

  const style = viewer.getStyle(layer.get('styleName'));
  if (style && style[0] && (!style[0][0].extendedLegend)) {
    content = getStyleContent(title, style);
  } else {
    content = getTitleWithIcon(title, '');
    const lType = layer.get('type');
    if (lType && lType.includes('WMS')) {
      content = await getWMSJSONContent(title);
    } else if ((lType && lType.includes('AGS')) || /\/arcgis\/services\/[^/]+\/[^/]+\/MapServer\/WMSServer/.test(getOneUrl(layer))) {
      content = await getAGSJSONContent(title, layer.get('id'));
    }
  }

@Grammostola Grammostola merged commit 65fdb72 into master Oct 30, 2023
4 checks passed
@Grammostola Grammostola deleted the print-legend-wms-else-fix branch October 30, 2023 15:07
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.

Print legend handles geojson layers without a title in a suboptimal way
2 participants