Skip to content

Commit

Permalink
[Fixes #508] Exclude vector layers from the preview legend (#518)
Browse files Browse the repository at this point in the history
* [Fixes #508] Exclude vector layers from the preview legend

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>

* - fix data to new maps

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
  • Loading branch information
marthamareal and mattiagiupponi authored Oct 13, 2021
1 parent 1377597 commit f7c482d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mapstore2_adapter/plugins/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import absolute_import
from uuid import uuid4
from copy import deepcopy

from rest_framework.exceptions import APIException
import json
Expand Down Expand Up @@ -60,10 +61,10 @@ def set_geonode_map(self, caller, serializer, map_obj=None, data=None):
_map_name = serializer.validated_data['title'] or map_obj.title
_map_title = serializer.validated_data['title'] or map_obj.title
_map_abstract = serializer.validated_data.get('abstract', '') or '' if not hasattr(map_obj, 'abstract') else map_obj.abstract

if data:
try:
data_blob = data.copy()
data_blob = serializer.validated_data.get('blob') or data.copy()
_map_conf = dict(data)
_map_conf["about"] = {
"name": _map_name,
Expand Down Expand Up @@ -208,11 +209,15 @@ def set_geonode_map(self, caller, serializer, map_obj=None, data=None):
serializer.instance = map_obj
serializer.save()

# filter annotations
new_conf = deepcopy(_map_conf)
new_conf['map']['layers'] = [x for x in new_conf['map']['layers'] if x['type'] != 'vector']

serializer.instance.update_from_viewer(
_map_conf,
context={'config': _map_conf})
new_conf,
context={'config': new_conf})
return serializer

except Exception as e:
tb = traceback.format_exc()
logger.error(tb)
Expand Down

0 comments on commit f7c482d

Please sign in to comment.