How to set up the Query tool on a map
Let viewers draw an area or choose all features, add attribute filters, and see matches on the map and in a table. They can also export results.
The Query tool lets viewers draw an area or choose “all features”, add attribute filters, and see matching features on the map and in a results table. They can also export CSV, Shapefile, or KML files and print a report. Add it from the map’s Extensions page. It supports vector layers and one dataset per query. A map can hold several queries in one panel.
See it on an example map
Open the Singapore Search & Query Lab. Click Query buildings in the toolbar. Choose a drawing tool and draw a shape on the map. You can also set a class or a height filter. Click Search. The tool lists the buildings in the shape and shows a short report.
Before you start
- You need edit access to the map.
- The map needs at least one vector layer for each query you want to create. Raster and WMS layers don’t support attribute or spatial querying.
- Decide which queries you need. Each query uses one dataset and its own filters, spatial tools, and report. A common pattern is one query for each task, such as “Find parcels”, “Find assets”, or “Find inspections”.
- For each query, decide which measurement unit to default to (
Meters,Kilometers,Feet, orMiles). The unit is required; you can’t save a query without picking one. Viewers can change the unit at run time. - For each query, decide whether you need a report. Reports are rich-text outputs that can include variable placeholders (drawn from the result set) and aggregate functions (sum, count, average, min, max, median). If you only need a results table, leave the report off.
Open the Extensions page
From the map’s admin sidebar, click Extensions. The Query card is in the row below Advanced Search.
Enable Query
Click the Add button on the Query card. The Query settings page opens.
Configure the tool name, description, and highlight colour
The first card on the page is Query Tool Configuration. Three fields:
Query tool name— required. Defaults toQuery. Change it to something map-specific (“Asset finder”, “Spatial query”) so viewers know what the panel does.Description— optional rich-text field shown at the top of the Query panel.Highlight Colour— the colour MangoMap uses to highlight matching features on the map after a query runs. Defaults to red. Helper text:Colour used to highlight selected features in the map.
Click Save Changes at the bottom of this card to save tool-level changes.
Add a query configuration
Add at least one named query before viewers can use the tool. Click Add Query in the page header (top-right). A modal opens listing the map’s vector datasets. Click the dataset you want this query to point at.
The page opens the per-query form. Configure:
Source dataset— the dataset you picked. You can’t change it; to use another dataset, delete the query and add a new one.Query title— the name viewers see in the query picker. Defaults to the dataset’s layer name. Override to make it action-oriented (“Find parcels by ID”, “Look up assets near a site”).Description (optional)— rich text shown when this query is selected. Same rich-text extension set as the tool-level description.Filter attributes— pick the attribute fields viewers can filter on. Each field becomes a filter in the panel when this query is active.Spatial selection tools— tick the tools viewers can use to choose features by location:Point Selection(click features),Rectangle Selection,Circle Selection,Polygon Selection(draw an area), andSelect All(every feature in the layer, with no drawing).Measurement units— required. Choices:Meters,Kilometers,Feet,Miles. Viewers can change this at run time.
Results:Generate results table— tick to show a table of matching features in the results panel.Generate report— tick to add a report to the results panel. This shows theReport contenteditor and theReport preview.
Report content— a rich text editor for aggregate variables (sum, count, average, min, max, median), equations, charts, and conditional content. Use it to build a printable summary of every query result. See Report templating syntax.
Report preview— shows the text of the report, without its headings, styles, or line breaks. It does not read your data: an aggregate variable such as{height:sum}shows as you typed it. An equation shows a message such asNo sample value for height:sum.Results export— same export checkboxes as Advanced Search:CSV(withInclude coordinates),Shapefile,KML.
When you finish the query, click Save Changes at the bottom of the form. Validation requires the measurement unit (Measurement unit is required); the title is otherwise optional.
The page returns to the main Query settings, and the new query appears in the configured-queries list.
Edit, reorder, or delete a query
The configured-queries list shows each query as a card with controls:
- Drag handle — drag a card up or down to reorder. The order here is the order viewers see in the panel’s query picker.
- Edit (pencil) — opens the per-query configuration form again with the current values. Save Changes to apply.
- Delete (trash) — removes the query after a confirmation dialog. Removing a query doesn’t affect the underlying dataset.
(Optional) Set Query to open on load
Back on the Extensions page, the Query card now shows Settings, Remove, and an Open on load chip. Click the chip to make Query the panel that opens automatically when viewers open the map. Only one tool can be Open on load at a time.
For a map with one clear query task, Open on load takes viewers straight to the tool.
Verify the result
Open the map in a viewer-state session. The Query tool’s button should appear in the toolbar — or the panel should be open if you set Open on load. Confirm:
- The tool name and description match.
- The query picker lists every query you added, in the order you set.
- Picking a query reveals its description, attribute filters, and spatial selection tools.
- Running a query with each spatial tool returns matches, highlights them on the map in the configured colour, and shows the results table and report you enabled.
Download resultsoffers the formats you ticked for the query.
If the spatial tools don’t all work, return to the per-query form and check the tick boxes. If the report shows N/A, check each {field:function} against the dataset’s field names; the Report preview does not catch a wrong field name.
What this doesn’t cover
- Attribute-only filtering on a single layer — use Advanced Search (
/docs/map-extensions/set-up-advanced-search). Simpler, faster setup when you don’t need a spatial dimension. - Proximity-based filtering — for “find features within X distance of a reference feature”, use Proximity Analysis (
/docs/map-extensions/set-up-proximity-analysis). Query draws an area and finds features in it; Proximity Analysis picks a feature and finds others near it. - Per-feature popups — Query opens the layer’s popup on click. Configure popups in Configuring popups.
- Report templating syntax in depth — aggregate variables, equations, and operators are documented in Report templating syntax, shared with Proximity Analysis reports.