Select to view content in your preferred language

Pass custom parameters along with require construct

148
1
Jump to solution
08-09-2024 11:20 AM
RakeshAjwani
New Contributor

Hi there,

            This is just a requirejs question rather than specific to arcgis sdk. I need to pass custom parameters to my query function. 

 

Here is my query function, I am not able to pass more parameters in the require construct. I am using function as a part of a bigger js file that will contain other map functions. I need to pass canal and lateral while calling that function. 

Below errors out. If I remove canal and lateral and just add it to the function definition they are always undefined.

let queryFeature = (canal,lateral) => {
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/layers/FeatureLayer", canal,lateral
], function (esriConfig, WebMap, MapView, FeatureLayer,canal,lateral) {
//query features layer, which is the layer with gates. Feature # or URL needs to be stored in the config
console.log(canal);
console.log(lateral);
});
}

 

 

Any help or guyidance is appreciated. Thanks

0 Kudos
1 Solution

Accepted Solutions
RakeshAjwani
New Contributor

Nevermind, I figured it out. It needs to be like below. I needed to remove it from the require section.

let queryFeature = (canal,lateral) => {
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/layers/FeatureLayer",
], function (esriConfig, WebMap, MapView, FeatureLayer) {
//query features layer, which is the layer with gates. Feature # or URL needs to be stored in the config
console.log(canal);
console.log(lateral);
});
}

 

View solution in original post

0 Kudos
1 Reply
RakeshAjwani
New Contributor

Nevermind, I figured it out. It needs to be like below. I needed to remove it from the require section.

let queryFeature = (canal,lateral) => {
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/layers/FeatureLayer",
], function (esriConfig, WebMap, MapView, FeatureLayer) {
//query features layer, which is the layer with gates. Feature # or URL needs to be stored in the config
console.log(canal);
console.log(lateral);
});
}

 

0 Kudos