From 9feb23a5cbeec30da36a89bde64b7183db4cc8b8 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 10 Nov 2021 09:44:26 +0100 Subject: [PATCH] maps: keep the marker's colour property (#58072) --- combo/apps/maps/models.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/combo/apps/maps/models.py b/combo/apps/maps/models.py index dde62eca..4642faa5 100644 --- a/combo/apps/maps/models.py +++ b/combo/apps/maps/models.py @@ -252,20 +252,27 @@ class MapLayer(models.Model): else: features = data - properties = [] if self.properties: - properties = [x.strip() for x in self.properties.split(',')] + property_names = [x.strip() for x in self.properties.split(',')] + properties = features['properties'] for feature in features: if 'display_fields' in feature['properties']: # w.c.s. content, filter fields on varnames feature['properties']['display_fields'] = [ - x for x in feature['properties']['display_fields'] if x.get('varname') in properties + x + for x in feature['properties']['display_fields'] + if x.get('varname') in property_names ] else: # classic geojson, filter properties feature['properties'] = dict( - [x for x in feature['properties'].items() if x[0] in properties] + [x for x in feature['properties'].items() if x[0] in property_names] ) + # keep the property for marker's colour + if self.marker_colour and not self.marker_colour.startswith('#'): + first_dotted_name = self.marker_colour.split('.')[0] + if first_dotted_name in features['properties']: + features['properties'] = properties[first_dotted_name] if request and not self.geojson_accepts_circle_param and distance_params: geod = pyproj.Geod(ellps='WGS84') -- 2.33.0