AnsweredAssumed Answered

Read in a .txt file

Question asked by gsalvador0 on Aug 9, 2017
Latest reply on Aug 10, 2017 by TSolow-esristaff

Hi all,


Basic question here, but how do I read in a .txt file and store it as an array? I am using javascript and arcgis' 4.4 API


I have several layers on a map that I want "visible = true" on startup. Instead of hard coding the titles of the layers in a giant if() statement, I would like to read in the titles from a text file. I think a simple array would be best to save the read in data. Once read in, I will loop through the array and access the desired layerViews that way.


What I'm currently doing:

if (item.title === "City Limits" || item.title === "Land" ||

item.title === "Parcels" || item.title === "Boundary" ||

item.title === "Fill" || item.title === "Other Cities & Towns Boundaries" || item.title === "Other Cities & Towns Fills") {

item.visible = true;


What I would Like to Do:

for(i = 0; i < dataArray.length; i++){

if(item.title === dataArray[i])

item.visible = true;



I have found reference material that mentions javascript's Node.js File System Module, so if that could be incorporated into my main .js script I would be a happy camper.