File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -253,6 +253,48 @@ class GeoJSONSource extends Evented<SourceEvents> implements ISource {
253253 return this ;
254254 }
255255
256+ /**
257+ * Sets filter for the GeoJSON data source and re-renders the map.
258+ *
259+ * @param {Array | string } filter An array for the filter expression.
260+ * @returns {GeoJSONSource } Returns itself to allow for method chaining.
261+ * @example
262+ * map.addSource('source_id', {
263+ * type: 'geojson',
264+ * data: {
265+ * "type": "FeatureCollection",
266+ * "features": [{
267+ * "type": "Feature",
268+ * "properties": {"name": "Null Island"},
269+ * "geometry": {
270+ * "type": "Point",
271+ * "coordinates": [ 0, 0 ]
272+ * }
273+ * },
274+ * {
275+ * "type": "Feature",
276+ * "properties": {"name": "Another Island"},
277+ * "geometry": {
278+ * "type": "Point",
279+ * "coordinates": [ 1, 1 ]
280+ * }
281+ * }]
282+ * }
283+ * });
284+ * const geojsonSource = map.getSource('source_id');
285+ * // Update the filter after the GeoJSON source was created
286+ * geojsonSource.setFilter([
287+ * "==",
288+ * ["get", "name"],
289+ * "Another Island"
290+ * ]);
291+ */
292+ setFilter ( filter : Array | string ) : this {
293+ this . workerOptions = extend$1 ( { filter : filter } , this . workerOptions ) ;
294+ this . _updateWorkerData ( ) ;
295+ return this ;
296+ }
297+
256298 /**
257299 * For clustered sources, fetches the zoom at which the given cluster expands.
258300 *
You can’t perform that action at this time.
0 commit comments