Skip to content

Filtering Layers

When using vector layers it might be useful to work with a subset of features. About that, MapStore let you set up a Layer Filter that acts directly on a layer with WFS available and filter its content upfront.
The map will immediately update when a filter is created and all other tools will take it into consideration when used. More over, the filter is saved into the map context so if you save it the filter will apply when you open the map next time.

Creating a new Layer Filter

As we said in this section, is it possible to set up a Layer Filter from the button of the TOC toolbar. Select a vector layer and click on it to see the toolbar.

The following steps show you how to filter that layer:

  • Click on the button to open the Query Builder.

  • Set up a filter. In this example we will draw a region of interest on the map to perform a spatial query:

    • Select a Filter Type (a Rectangle for example), you can choose between these spatial objects:

      • Viewport
      • Rectangle
      • Circle
      • Polygon
    • Select a Geometric Operation (Intersect could be fine), you can choose between these operations:

      • Intersect
      • Is contained
      • Contains

      A message suggest you to draw the region of interest on the map, so do it to complete the filter creation.

    • Draw a rectangle on the map

  • Click the Apply button of the Query Builder toolbar, the map updates immediately.

  • Click on Save button to make it persistent. It means the filter will take effect whenever using the layer even if the Query Builder is closed.

A filter icon is shown in the TOC right next to the layer title to notify that the layer is filtered. The Filter Icon is toggleable to temporarily disable the filter anytime.

Layer Filter Persistence

Once the filter has been saved the filter becomes persistent along with the other layer options and inside the map object on map save.

If you try to retrieve the features information through a click on the map, the filter you have created is applied to the content you get:

The layer Attributes Table also takes the filter into account:

Any additional filter you define using the Advanced Filtering tool or the Quick Filter will overlap the layer filter.
Layer Filter will go in AND with Advanced Filtering:

Layer Filter will go in AND with Quick Filter:

When saving a map the Layer Filter is saved along with it, so if you reload the map the filter will still be active.

Modifying a Layer Filter

If you want to change the Layer Filter configuration you have to click the Filter Layer button in the TOC toolbar so that the Query Builder opens.

  • Modify the existing filter (adding new conditions for example)

  • Click on Apply so that the map updates

  • Click on Save to make the filter persistent

The Query Builder toolbar makes also available the Undo button to discard applied changes to the filter since the last save (so it is disabled if no changes are made after the last save).

Removing a Layer Filter

When opening the Query Builder of a filtered layer, the filter is already configured.
The Reset button is the only one enabled and it allows you to clear the filter (it restores an empty filter):

  • Click on Reset , an empty filter will be configured and the map updates immediately.

  • Click on Save to make the state persistent or Click Undo to restore the previous saved filter.

An example in the following gif: