POST
|
Go to ..\arcgis-web-appbuilder-2.7\WebAppBuilderForArcGIS\server\apps\xx\jimu Modify MapUrlParamsHandler.js (make a backup) Add: In mo.postProcessUrlParams = function(urlParams, map) add if('filter' in urlParams){ setSpecialZoom(urlParams, map);} 3 functions function setSpecialZoom(queryObject, map){ //myZooms is a keyValue string, separated by ; char, key is layerObject Id, values are filters, separated by * var myZooms = queryObject.filter.split(";"); if (myZooms.length < 1) {console.error("No arguments in specialzoom");return;} var layersKeyValue = {}; for (myLayer in myZooms){ //iterate over each itemid myLayer = myZooms[myLayer]; layerAndFilter = myLayer.split("*"); if (layerAndFilter.length < 2){console.error("LayerObject, ID or filters are missing");return;} var layerFilters = []; layerId = layerAndFilter[0]; for ( i = 1; i < layerAndFilter.length; i++){ //iterate over each id in item id layerFilters = processFilter(layerFilters,layerAndFilter.split("|")); } layersKeyValue[layerId] = layerFilters; } assignFilterPropertiesToLayer(layersKeyValue,map); //var valuesForProcess = [myZooms[0]]; //map.itemInfo.itemData.operationalLayers[0].layerObject.setLayerDefinitions( valuesForProcess); } function processFilter (layerFilters,myFilters){ //creates a string structure from all the filters. var andString = " AND "; var filterCombined = ""; var layerId = myFilters[0] for (j = 1; j < myFilters.length;j++) { currentFilter = myFilters ; // currentFilter = "(" + currentFilter + ")"; if (filterCombined.length == 0){ filterCombined = currentFilter; }else{ filterCombined = filterCombined + andString + currentFilter; } } layerFilters[layerId] = filterCombined; return layerFilters; } function assignFilterPropertiesToLayer (layersKeyValue,map){ //loop over all operational layers and set new filter if necessary for (myOperLayer in map.itemInfo.itemData.operationalLayers){ myOperLayer = map.itemInfo.itemData.operationalLayers[myOperLayer]; if (myOperLayer.id && layersKeyValue[myOperLayer.id]){ myOperLayer.layerObject.setLayerDefinitions(layersKeyValue[myOperLayer.id]); } } } How to use in URL : Add "filter=" in url separated by ; between Map services separated by * between itemid and id (Service Features in a Map service) separated by | between field Values example : ?filter=3fb26b36ed2d43f48c63770fc50bc7f8*0|Unit_Code=26|Measure_Code=285*1|branch_code=26|Measure_Code=285*2|Measure_Code=285;b26b36ed2d43f48c63770fc50bc7f8*0|Unit_Code=26|Measure_Code=285; ITEMID ID Field Values
... View more
06-03-2019
11:24 PM
|
3
|
2
|
900
|
POST
|
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); } }); }
... View more
03-29-2017
05:32 AM
|
0
|
8
|
1199
|
POST
|
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 !
... View more
03-27-2017
05:34 AM
|
0
|
10
|
1199
|
POST
|
Right - my question is if if it possible to do? and how ?
... View more
03-27-2017
05:16 AM
|
0
|
12
|
1199
|
POST
|
The "Query a feature" only zooms in and select the feature and does not filter the data ( removes all other features )
... View more
03-27-2017
05:04 AM
|
0
|
14
|
1199
|
POST
|
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=MYLAYER, 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 https://community.esri.com/community/gis/web-gis, https://community.esri.com/community/gis/web-gis/web-appbuilder, https://community.esri.com/community/developers, https://community.esri.com/community/developers/web-developers
... View more
03-26-2017
03:50 AM
|
0
|
1
|
710
|
POST
|
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=MYLAYER, 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
... View more
03-26-2017
03:21 AM
|
0
|
17
|
3701
|
Title | Kudos | Posted |
---|---|---|
3 | 06-03-2019 11:24 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|