Select to view content in your preferred language

Create a renderer using Arcade Expressions

1948
17
01-31-2019 09:22 AM
HushamMohamed
Regular Contributor

I am creating simple election map,  that visualize the result over the county by  Some election races, which I listed them on accordion Panel.  I tried to follow this  example , to render the feature layer. I failed to Add the following

1- Add on Click Events on the Race Accordion header then render the map according. by replacing the field names in the Arcade Expression

(on console log I was able to get all the fields name)

2-  instead of placing the arcade expression on the HTML file (script tag)  How can I add it to my separated js file(script.js).

I do appreciate your help.

Attaching my code so far.

0 Kudos
17 Replies
HushamMohamed
Regular Contributor

Yes correct ,  and I have console.log to  get the field names.

the problem I don't have any luck passing the array to the arcade expression,  so I can get feature render accordingly

    console.log(selectedAccordion);
        console.log(currentCandidates);
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Hmm.. Not sure you can do that. You can use the code I provided earlier to write a new expression though.

0 Kudos
HushamMohamed
Regular Contributor

that sound good for me,   could you please rewrite your code you are referring to  with the expression,  then will try to finalize the rest.

Thank you for your help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I can't help you that much but here is a start.

var s = document.createElement('script');
s.type = 'text/javascript';
var code = 'alert("hello world!");';
try {
  s.appendChild(document.createTextNode(code));
  document.body.appendChild(s);
} catch (e) {
  s.text = code;
  document.body.appendChild(s);
}‍‍‍‍‍‍‍‍
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
HushamMohamed
Regular Contributor

Thank you Robert,

Will work on that

0 Kudos
HushamMohamed
Regular Contributor

hi, 

still trying to figure out how to use your code to write new expression, without any luck.

Regards

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Husham,

  Sorry I have never done that before either so I don't have any more advice.

0 Kudos
HushamMohamed
Regular Contributor

Thank you   Robert,  I am just not trying pushing you,  just updating you

Thanks for all help.

0 Kudos