Summary
In ArcGIS Enterprise and ArcGIS Online, custom parameters can be used in Map Viewer to spatially filter data based on a custom polygon. Use this workflow when it is necessary to limit a feature layer to features that intersect a specific polygon, without creating a new derived layer or running analysis tools.
Cause
In some cases, you may want to limit the spatial extent of data but are unable to do so using a standard filter. Common scenarios include:
- The layer does not contain an attribute field that can be used for filtering.
- The dataset is very large and using analysis tools would consume excessive credits.
- You need to restrict features to a specific geographic area without creating a new dataset.
Custom parameters allow filtering directly at the service level by passing a polygon geometry to the layer query. This can reduce the amount of data returned and improve map performance.
Procedure
Follow the steps below to retrieve the polygon geometry and use it in the target layer custom parameters.
- Determine the polygon to use as the filter:
Identify the polygon that defines the spatial filter. In this example, a state boundary layer is used to obtain the geometry for Iowa. The goal is to filter a large bridge condition dataset so that only features within Iowa are returned.


- Find the polygon ObjectID:
Open the polygon layer in Map Viewer, go to the Data tab, enable the OBJECTID field through Column Visibility, and note the ObjectID value for the selected polygon. In the example, Iowa has an OBJECTID of 16.

- Retrieve the polygon geometry from the REST service:
Open the layer Item Details page, select View under the layer URL, select the polygon layer in the REST Services Directory, and use the Query operation. Enter the ObjectID, set Format to JSON, and select Query (GET).


- Copy the geometry information:
From the JSON response, capture the spatialReference wkid value and the geometry rings array. The rings array contains the polygon vertices used as the spatial filter geometry.

- Configure custom parameters in Map Viewer:
Open the layer to filter, open the Properties pane, scroll to Custom parameters, and select Add parameter to add each of the required parameters: geometryType, spatialRel, and geometry.

|
Parameter
|
Value
|
|
geometryType
|
esriGeometryPolygon
|
|
spatialRel
|
esriSpatialRelIntersects
|
|
geometry
|
Polygon rings JSON with matching spatialReference wkid (see below)
|
{
"rings": [
[
[-91.1201324198553, 40.7054431242584],
[-91.1293029781382, 40.6821890161974],
[-91.1626444205684, 40.6563524249651],
[-91.2150600067229, 40.6438594146109]
// Additional vertices omitted for brevity
]
],
"spatialReference": { "wkid": 4326 }
}
The geometry value must contain the complete rings array copied from the REST query results. The sample above is abbreviated for readability. Ensure the geometry parameter includes the spatialReference wkid returned by the REST query.
- Verify the results:
After the parameters are applied, the layer query is limited to features that intersect the polygon. In this example, the bridge condition layer is restricted to features intersecting Iowa.
