maps: include layer attributes in a sub property (#16683)
This commit is contained in:
parent
c8ce46abd0
commit
c77ebe0010
|
@ -99,10 +99,13 @@ class MapLayer(models.Model):
|
|||
else:
|
||||
features = data
|
||||
for feature in features:
|
||||
feature['properties']['colour'] = self.marker_colour
|
||||
feature['properties']['icon_colour'] = self.icon_colour
|
||||
feature['properties']['label'] = self.label
|
||||
feature['properties']['icon'] = self.icon
|
||||
feature['properties']['layer'] = {
|
||||
'colour': self.marker_colour,
|
||||
'icon_colour': self.icon_colour,
|
||||
'label': self.label,
|
||||
'icon': self.icon,
|
||||
'identifier': self.slug
|
||||
}
|
||||
return features
|
||||
|
||||
|
||||
|
|
|
@ -31,10 +31,12 @@ $(function() {
|
|||
$(cell).trigger('combo:map-feature-prepare', {'feature': feature, 'layer': layer});
|
||||
},
|
||||
pointToLayer: function (feature, latlng) {
|
||||
var markerStyles = "background-color: "+feature.properties.colour+";";
|
||||
var markerStyles = "background-color: " + feature.properties.layer.colour + ";";
|
||||
marker = L.divIcon({iconAnchor: [0, 30],
|
||||
popupAnchor: [5, -45],
|
||||
html: '<span style="' + markerStyles + '"><i class="leaflet-marker-icon '+feature.properties.icon+'" style="color:'+feature.properties.icon_colour+'"></i></span>'
|
||||
html: '<span style="' + markerStyles + '"><i class="leaflet-marker-icon ' +
|
||||
feature.properties.layer.icon + '" style="color:' +
|
||||
feature.properties.layer.icon_colour +'"></i></span>'
|
||||
});
|
||||
return L.marker(latlng, {icon: marker});
|
||||
}
|
||||
|
|
|
@ -90,10 +90,11 @@ def test_download_geojson(mock_request, app, admin_user):
|
|||
assert item['type'] == 'Feature'
|
||||
assert item['geometry']['type'] == 'Point'
|
||||
assert item['geometry']['coordinates'] == [2.3233688436448574, 48.83369263315934]
|
||||
assert item['properties']['icon'] == 'bicycle'
|
||||
assert item['properties']['label'] == 'Test'
|
||||
assert item['properties']['colour'] == '#FFFFFF'
|
||||
assert item['properties']['icon_colour'] == '#000000'
|
||||
assert item['properties']['layer']['identifier'] == layer.slug
|
||||
assert item['properties']['layer']['icon'] == 'bicycle'
|
||||
assert item['properties']['layer']['label'] == 'Test'
|
||||
assert item['properties']['layer']['colour'] == '#FFFFFF'
|
||||
assert item['properties']['layer']['icon_colour'] == '#000000'
|
||||
|
||||
mocked_response.json.return_value = {'type': 'FeatureCollection',
|
||||
'features': [{'geometry': {'type': 'Point',
|
||||
|
@ -109,7 +110,8 @@ def test_download_geojson(mock_request, app, admin_user):
|
|||
for item in geojson:
|
||||
assert item['geometry']['type'] == 'Point'
|
||||
assert item['geometry']['coordinates'] == [2.3233688436448574, 48.83369263315934]
|
||||
assert item['properties']['icon'] == 'bicycle'
|
||||
assert item['properties']['label'] == 'Test'
|
||||
assert item['properties']['colour'] == '#FFFFFF'
|
||||
assert item['properties']['icon_colour'] == '#000000'
|
||||
assert item['properties']['layer']['identifier'] == layer.slug
|
||||
assert item['properties']['layer']['icon'] == 'bicycle'
|
||||
assert item['properties']['layer']['label'] == 'Test'
|
||||
assert item['properties']['layer']['colour'] == '#FFFFFF'
|
||||
assert item['properties']['layer']['icon_colour'] == '#000000'
|
||||
|
|
Loading…
Reference in New Issue