Hello all,
I am trying to display the sustainable development goals (SDG's) in a popup based on an input in the feature. I have written the code in Arcade which works if one SDG is mentioned in the feature. However, problem arises if one input has multiple SDG's (i.e. '1, 4, 5'). A function cannot return multiple links for an image. I was curious if there is a workaround for this?
See my code below:
// input of data i.e. '1, 4, 12'
var data_atr = $feature["SDG_s"]
var list = Split(data_atr, ' ')
// deleting space
var result = ''
for (var i in list) {
if (!IsEmpty(list[i])){
if (result == ''){
result = list[i]
} else {
result += list[i]
}
}
}
// splitting of numbers
var sdgs = split(result, ',')
var url = ''
var baseurl = 'https://i1.wp.com/www.un.org/sustainabledevelopment/wp-content/uploads/2019/08/E-Goal-'
var extension = '.png?resize=200%2C200&ssl=1'
// making of counter
for (i = 1; i <= 17; i++) {
// iterate over sdgs
for (var j in sdgs){
// adding '0' in the link
if (i < 10) {
if (number(sdgs[j]) == i) {
url = baseurl + '0' + i + extension
console(url)
return url
}
} else if (i > 10) {
if (number(sdgs[j]) == i) {
url = baseurl + i + extension
console(url)
return url
}
}
}
}
I have wondered if you could index a expression so you could add the images manually.
Could somebody steer me in the right direction?