Skip to content

Commit

Permalink
Merge pull request #4211 from rldhont/fix-getlegendgraphic-json-no-nodes
Browse files Browse the repository at this point in the history
[Bugfix] WMS GetLegendGraphic for no symbols layer
  • Loading branch information
rldhont authored Feb 15, 2024
2 parents b7c7813 + 6f97d89 commit 51171c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lizmap/modules/lizmap/lib/Request/WMSRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ protected function process_getlegendgraphic()
if ($result->code == 200) {
$layer = $this->project->findLayerByAnyName($lName);
$nodes = json_decode($result->data)->nodes;
if (!$nodes) {
return $result;
}
// Rework nodes
if ($layer->groupAsLayer == 'True' | $layer->type == 'group') {
// Create a dedicated node for group
Expand Down Expand Up @@ -372,7 +375,9 @@ protected function process_getlegendgraphic()
return $result;
}
$nodes = json_decode($result->data)->nodes;
$legends['nodes'][] = $nodes[0];
if ($nodes) {
$legends['nodes'][] = $nodes[0];
}
}

return new OGCResponse(200, 'application/json', json_encode($legends));
Expand Down

0 comments on commit 51171c3

Please sign in to comment.