Trying to auto refresh map services

1059
5
Jump to solution
05-14-2013 10:40 AM
DeannaIrving
New Contributor III
I'm am very new to javascript programming and am trying to autorefresh some layers in my web map. I've attached my code...any insight would be extremely helpful.
0 Kudos
1 Solution

Accepted Solutions
JianHuang
Occasional Contributor III
The logic looks right. Some things to look at:
1. The syntax of setInterval function: http://www.w3schools.com/jsref/met_win_setinterval.asp
2. Make sure you understand the variable scope in JavaScript: http://stackoverflow.com/questions/500431/javascript-variable-scope
In your code, you cannot access those layers which you created in another function, because they are the local variables. You can either set them as global variables, (normally, you should avoid doing so), or pass it as an argument.

View solution in original post

0 Kudos
5 Replies
JianHuang
Occasional Contributor III
The logic looks right. Some things to look at:
1. The syntax of setInterval function: http://www.w3schools.com/jsref/met_win_setinterval.asp
2. Make sure you understand the variable scope in JavaScript: http://stackoverflow.com/questions/500431/javascript-variable-scope
In your code, you cannot access those layers which you created in another function, because they are the local variables. You can either set them as global variables, (normally, you should avoid doing so), or pass it as an argument.
0 Kudos
DeannaIrving
New Contributor III
Thanks for the insight. I finally got it working.
0 Kudos
derekswingley1
Frequent Contributor
Thanks for the insight. I finally got it working.


Hi Deanna,

Did you mean to mark your post as the answer to this thread? If anything, it seems like Jian's post is more appropriate to be marked as the answer for this thread. If his post didn't help, please add specifics to your post about what you did to address your problem.
0 Kudos
DeannaIrving
New Contributor III
Sorry about that, I should not have checked my response.
0 Kudos
derekswingley1
Frequent Contributor
Thanks for fixing!
0 Kudos