I am trying to loop through layers and this block of code works:
var jsonValue, signUrl, supportUrl;
var restEndPoint = "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/";
var config;
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: {
f: 'json'
},
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name = "Support") {
jsonValue = lyrJSON.layers.id;
supportUrl = restEndPoint + jsonValue;
}
}
// app configuration
config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/0",
supportLayerUrl: supportUrl
};
initMap();
})But when I try to add the following code, I can't assign the value to signLayerUrl. I even tried to change i to t for the second if statement:
var signValue, signUrl, supportValue, supportUrl;
var restEndPoint = "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/";
var config;
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: {
f: 'json'
},
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name = "Support") {
supportValue = lyrJSON.layers.id;
supportUrl = restEndPoint + supportValue;
}
if (lyrJSON.layers.name = "Sign") {
signValue = lyrJSON.layers.id;
signUrl = restEndPoint + signValue;
}
}
// app configuration
config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: signUrl,
supportLayerUrl: supportUrl
};
initMap();
})