Dynamic Filter

1686
17
03-26-2017 03:21 AM
Highlighted
New Contributor II

Hi,

We have an app that was created with webappbuilder 2.2 that only hold one layer.

This layer has 14 polygones and we want to send papramter to the map so it will open with the realvant polygone

instead of creating 14 diffrent apps / maps.

For example - 

http://gisserver/portal/apps/webappviewer/index.html?id=92fa9ecbb5cc433daa7ce8c9fe18cf45&FILTER=MYLA..., Code=1-14 ( 1,2,3...14 )

The same as here Use URL parameters to modify maps—ArcGIS Online Help | ArcGIS  but filter the data.

Hope i make myself clear..

Avishai

Reply
0 Kudos
17 Replies
Highlighted
MVP Esteemed Contributor
Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Avishai,

  So you are saying that you are having a hard time figuring out how to use the Query or find parameters?

Use URL parameters—Web AppBuilder for ArcGIS | ArcGIS 

Reply
0 Kudos
Highlighted
New Contributor II

   The "Query a feature" only zooms in and select the feature and does not filter the data ( removes all other features )

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

You can se from the help Doc I linked to there is no filter parameter. Only query and find.

Reply
0 Kudos
Highlighted
New Contributor II

Right - my question is if if it possible to do? and how ?

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor
Since it is not an OTB supported feature it would require an experienced developer using WAB developer edition to add the filter parameter to the code base.


Reply
0 Kudos
Highlighted
New Contributor II

Which code base would that be ? the map ? app ? and where can we find the file storing the code ? ( path / directory in the server )

We found out that the layerDefinition function does the filtering needed at the arcgisportal\content\items\query_..  file but how can we make it into a parmeter ?

Thanks !

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

You would have to get WAB developer edition to be able to work with the WAB code base and then you would have to host your customized WAB app on your own server as customized WAB apps can not be hosted on AGOL.

Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

The url parameters are handled in the [install dir]\server\apps\[app#]\jimu.jsMapUrlParamsHandler.js

Highlighted
New Contributor II

I guess my question is now how do I insert the 'layerDefinition' in order to filter the Feature instead of just selecting it ? 

selectFeatures(map, layer2, queryArray); & FilterFeatures(map, layer2, queryArray);

( or is there some other way doing so ? )

Thanks !

This is the "query" function syntax -

function queryFeature(queryObject, map){
/************************
?query=<layerName/layerId, fieldName, fieldValue>
?query=<layerName/layerId, whereClause>
*************************/
//?query=Cities,pop>1000&level=10
//?query=Cities,city_name,Rome&level=10
var queryArray = queryObject.query.split(";");
if (queryArray.length === 1) {
queryArray = queryObject.query.split(",");
}

if(queryArray.length !== 2 && queryArray.length !== 3){
console.error('query URL parameter is not correct.');
return;
}

var layerNameOrId = queryArray[0];
//by name first
getLayerByNameOrId('name', layerNameOrId, map).then(function(layer){
if(layer === null){
getLayerByNameOrId('id', layerNameOrId, map).then(function(layer2){
if(layer2 === null){
console.error('Invalid layer name or id.');
}else{
selectFeatures(map, layer2, queryArray);
}
});
}else{
selectFeatures(map, layer, queryArray);
}
});
}

Reply
0 Kudos