A community-supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit - https://cmv.io/
@TOldemeyer_gitlab You can create a new custom widget using this one as a starting point. It has the basics for querying a sublayer - in this case, to get metadata. (You can simplify the code greatly since that example does more than you need). You would do a similar query to get the complete extent for all features in the layer. A query that ends up something like this:
which returns this:
{
"extent": {
"xmin": -122.51129560300001,
"ymin": 33.75,
"xmax": -108.60000000000002,
"ymax": 38.100000000000023,
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
}
}
}
As part of your query, you'll want to reproject the coordinates into the spatial reference used by your map (usually Web Mercator, WKID 102100).
Here's a code snippet for adding the menu for the sublayers.
Hoping this is enough to get you going.
SublayerZoomTo:{
include: true,
type: 'invisible',
id: 'SublayerZoomTo',
path: 'dijit/_WidgetBase',
options: {
map: true,
startup: function() {
topic.subscribe('layerControl/SublayerZoomTo', lang.hitch(this, '_fetchExtent'));
},
_fetchExtent: function (event) {
var url = event.layer.url + '/' + event.subLayer.id + '/query?where=1%3D1&returnExtentOnly=true&outSR=' + this.map.spatialReference.wkid + '&f=json';
new Request({
url: url,
content: {
f: 'json',
}
})
.then(lang.hitch(this, function (result) {
if (result && result.extent) {
var extent = new Extent(result.extent);
this.map.setExtent(extent, true);
}
}))
.otherwise(lang.hitch(this, function (error) {
topic.publish('viewer/handleError', {
source: '_WidgetBase.SublayerZoomTo',
error: error
});
}));
},
_handleError: function(e) {
this._fetchExtent({
id: e,
name: 'Error',
description: 'The query could not execute.'
});
}
},
},
subLayerMenu: {
dynamic: [{
topic: 'SublayerZoomTo',
iconClass: 'fas fa-fw fa-search',
label: 'Zoom to Layer'
}]
},
Hi everyone, I need some help to get a previous value in expression into search widget to automatically updates the next expression, for example in the search configuration:
```
searchFields: [
{
field: 'STATE,
label: 'STATE',
expression: '(STATE LIKE \'%[value]%\')', // STORE THIS VALUE
unique: true,
includeBlankValue: true
},
{
field: 'CITY',
label: 'CITY',
where: 'STATE LIKE \'%[value]%\')', // AND PUT THE PREVIOS VALUE HERE
expression: '(CITY LIKE \'[value]%\')', // THIS WOULD BE A DIFFERENT VALUE
unique: true,
includeBlankValue: true
}
],
```
develop
branch, not the master branch. I have consistently used the code in the develop branch for all deployments of CMV for clients since at least 2015 or 2016 without issue. The code for demo app is continuously deployed with each commit to the develop branch. The developers here and elsewhere that I have interacted with on this topic also use the latest code. I hope this helps.
preload: true
. That is a fairly common mistake.
columns
array specifying the desired columns you want displayed. Instead of recreating that array in the configuration for each query (too much json), you can define all the columns in an array as a variable or object property, then clone that array for each query and show/hide columns as appropriate.
var cols1 = [
{
field: 'PDNAME',
label: 'Name',
width: 150
},
{
field: 'ADDRESS',
label: 'Address',
width: 150
},
{
field: 'PDTYPE',
label: 'Type',
width: 100
}
];
var cols2 = lang.clone(cols1);
cols2[1].hidden = true; // hides the address field
...
gridOptions: {
columns: cols2
},
...
@KhaledMona That method of using `'locale' in dojoConfig used to be supported by WAB but perhaps it isn't any longer in more recent versions of WAB. It seems to ignore it.
The default for WAB is to use the web browser's locale/language. When I change the language for my browser, the WAB widgets respond appropriately using the appropriate locale.
And most of the support for Web AppBuilder is in the Esri community forums: https://community.esri.com/community/gis/web-gis/web-appbuilder