Skip to content

Commit

Permalink
Fix default layer style url (#7368)
Browse files Browse the repository at this point in the history
Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
marthamareal and Alessio Fabiani authored Apr 22, 2021
1 parent e554102 commit 190e5f0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions geonode/maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,19 +584,13 @@ def get_legend(self):
layer_params = json.loads(self.layer_params)

capability = layer_params.get('capability', {})
style_name = capability.get('style')
if style_name:
if ':' in style_name:
style_name = style_name.split(':')[1]
href = Layer.objects.filter(title=self.layer_title).first().get_legend_url(style_name=style_name)
return {style_name: href}
else:
# use the default style on layer
layer_obj = Layer.objects.filter(alternate=self.name).first()
if layer_obj:
default_style_name = layer_obj.default_style.name
legend_url = layer_obj.get_legend_url(style_name=default_style_name)
return {default_style_name: legend_url}
# Use '' to represent default layer style
style_name = capability.get('style', '')
layer_obj = Layer.objects.filter(alternate=self.name).first()
if ':' in style_name:
style_name = style_name.split(':')[1]
href = layer_obj.get_legend_url(style_name=style_name)
return {style_name: href}
except Exception as e:
logger.exception(e)
return None
Expand Down

0 comments on commit 190e5f0

Please sign in to comment.