Skip to content

Commit 4b5479c

Browse files
committed
limit for geojson properties
1 parent 05daf53 commit 4b5479c

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/collective/collectionfilter/baseviews.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,11 @@ def data_geojson(self):
304304
"""Return the geo location as GeoJSON string.
305305
"""
306306
features = []
307+
locations = self.locations
308+
count = len(locations)
309+
limit = self.settings.geojson_properties_limit
307310

308-
for it in self.locations:
311+
for it in locations:
309312
if not it.longitude or not it.latitude:
310313
# these ``it`` are brains, so anything which got lat/lng
311314
# indexed can be used.
@@ -324,13 +327,14 @@ def data_geojson(self):
324327
}
325328
}
326329

327-
props = IGeoJSONProperties(it.getObject(), None)
328-
if getattr(props, 'popup', None):
329-
feature['properties']['popup'] = props.popup
330-
if getattr(props, 'color', None):
331-
feature['properties']['color'] = props.color
332-
if getattr(props, 'extraClasses', None):
333-
feature['properties']['extraClasses'] = props.extraClasses
330+
if count < limit:
331+
props = IGeoJSONProperties(it.getObject(), None)
332+
if getattr(props, 'popup', None):
333+
feature['properties']['popup'] = props.popup
334+
if getattr(props, 'color', None):
335+
feature['properties']['color'] = props.color
336+
if getattr(props, 'extraClasses', None):
337+
feature['properties']['extraClasses'] = props.extraClasses
334338

335339
features.append(feature)
336340

src/collective/collectionfilter/interfaces.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,15 @@ class ICollectionMapsSchema(ICollectionFilterBaseSchema):
286286
defaultFactory=map_layers_default,
287287
missing_value=[],
288288
value_type=schema.Choice(vocabulary='plone.formwidget.geolocation.vocabularies.map_layers')) # noqa: E501
289+
290+
geojson_properties_limit = schema.Int(
291+
title=_(
292+
u'geojson_properties_limit',
293+
default=u"Limit for GeoJSON properties"),
294+
description=_(
295+
u'help_geojson_properties_limit',
296+
default=u"If the search result is larger than this limit, no additional "
297+
"GeoJSON properties (like popup information) are shown."),
298+
required=False,
299+
default=500,
300+
)

0 commit comments

Comments
 (0)