# HG changeset patch # User Thierry Florac # Date 1612369682 -3600 # Node ID aaa7e73956b023c6f246463c90acea578415f98c # Parent 00784fe4c215f0e51ff32ec53b17aa659ae3dc03 Removed custom features from map paragraph default renderer diff -r 00784fe4c215 -r aaa7e73956b0 src/pyams_default_theme/component/paragraph/map.py --- a/src/pyams_default_theme/component/paragraph/map.py Wed Feb 03 17:27:34 2021 +0100 +++ b/src/pyams_default_theme/component/paragraph/map.py Wed Feb 03 17:28:02 2021 +0100 @@ -12,18 +12,12 @@ __docformat__ = 'restructuredtext' -import json - -from onf_website.component.location import ILocationInfo, ILocationTarget from pyams_content.component.paragraph.interfaces.map import have_gis -from pyams_gis.layer import GeoJSONLayer -from pyams_utils.interfaces import ICacheKeyValue -from pyams_utils.traversing import get_parent -from pyams_utils.url import absolute_url - if have_gis: + import json + from zope.schema.fieldproperty import FieldProperty from pyams_content.component.paragraph.interfaces.map import IMapParagraph @@ -109,55 +103,4 @@ i18n_context_attrs = ('title', ) def get_map_configuration(self): - configuration = self.settings.configuration - settings = self.settings - if settings.display_context_forests: - parent = get_parent(self.context, ILocationTarget) - if parent is not None: - key = ICacheKeyValue(parent) - layer = GeoJSONLayer() - layer.name = '{}-forests'.format(key) - layer.url = absolute_url(parent, self.request, 'get-location-forests.json') - layer.style = json.dumps({ - 'color': '#00dd00', - 'weight': '3', - 'opacity': '0.5' - }) - configuration.setdefault('layers', []).append(layer.get_configuration()) - if settings.set_bounds_to_forests: - configuration['fitLayer'] = layer.name - return json.dumps(configuration) - - def get_markers(self): - if not self.context.display_marker: - return None - if self.context.use_context_location: - parent = get_parent(self.context, ILocationTarget) - if parent is None: - return None - locations = ILocationInfo(parent).locations - if not locations: - return None - else: - if not self.context.gps_location: - return None - locations = [self.context.gps_location] - if not locations: - return None - config = { - 'icon': { - 'url': '/--static--/onf_website/images/leaflet-marker.png', - 'size': [47, 59], - 'anchor': [23, 58] - }, - 'clusterClass': 'onfCluster', - 'tooltipClass': 'onfTooltip', - 'markers': [] - } - append = config['markers'].append - for idx, location in enumerate(locations): - append({ - 'id': '{}::{}'.format(ICacheKeyValue(self.context), idx), - 'point': location.to_json() - }) - return json.dumps(config) \ No newline at end of file + return json.dumps(self.settings.configuration)