Select to view content in your preferred language

Popup Opening overrides the definition expression of feature layer (used for filtering locations)

75
1
Wednesday
MirzaMuhammadAhsanAli
Occasional Contributor

I am developing a custom widget in ArcGIS Experience Builder, I have apply the definition expression on a layer to filter the locations on the map(using a webmap from ArcGIS Enterprises portal in my application). 

The issue is when I click on the location to view the popup, all locations starts displaying on map and this (#data_s=id%3AdataSource_1-Risk_Database_Master_2_2642%3A100941) has been added in the url.

So, it seems that popups in experience builder is managed through the Data Source. Can anybody help me to resolve this issue. Any documentation or tutorial for the datasource.

OR 

Is it possible to disable this behaviour in ArcGIS Experience Builder, and handle the popup display programmatically.

@JeffreyThompson2 , @Ke_Xu , @ShengdiZhang 

Here , how i am applying filter through defination expression on feature layer.

    try {
          // find the layer(risk locations) in the map to alter the definationexpression according to selected tile where clause 
          const layer: any = jimuMapView.view.map.layers.find((layer: any) => layer?.url === tile.layer);
          if (layer) {
            // Apply query as a definition expression
            layer.definitionExpression = tile.whereClause;
            await layer.refresh();

            // Optional: Zoom to features
            const queryParam = new Query({
              where: tile.whereClause,
              returnGeometry: true,
              // outFields: ['*'],
            });
            const result = await query.executeQueryJSON(tile.layerUrl, queryParam);
            if (result.features.length > 0) {
              await jimuMapView.view.goTo(result.features.map((f) => f.geometry));
            }
            else {
              await jimuMapView.view.goTo(jimuMapView.view?.map.initialViewProperties?.viewpoint?.targetGeometry);
            }
          } else {
            console.warn(`Layer with URL ${tile.layerUrl} not found in map`);
            console.log('Available layers:', jimuMapView.view.map.layers.toArray());
          }
        } catch (error) {
          console.error('Error applying query to map:', error);
        }


Best Regards,

0 Kudos
1 Reply
JeffreyThompson2
MVP Frequent Contributor

I am currently working on a Custom Filter Widget and also discovered that definitionExpressions don't really work. You will need to create your filter at the dataSource level. Here is the official example: https://github.com/Esri/arcgis-experience-builder-sdk-resources/tree/master/widgets/filter-feature-l...

And this is the most important block of code.

// First get the DataSourceManager instance
const dsManager = DataSourceManager.getInstance();

// Get the data source using useDataSource.dataSourceId
const useDataSource = props.useDataSources[0];
const ds: FeatureLayerDataSource = dsManager.getDataSource(useDataSource.dataSourceId) as FeatureLayerDataSource;

// Build the queryParams, with the configured filterField and the value
// that has been typed into the TextInput by the user
const queryParams: SqlQueryParams = {
  where: `${props.config.filterField} LIKE '%${evt.target.value}%'`
};

// Filter the data source using updateQueryParams function.
ds.updateQueryParams(queryParams, props.id);
GIS Developer
City of Arlington, Texas
0 Kudos