Mobile: Dynamic javascript variable names not working


I'm currently working on the Leaflet mobile component and am trying to beef that up a little just like I did with the web counterpart. One of the things that I'm running into is the following;

I'm trying to create a javascript object ($parameters.MarkerName). As you can see an error is thrown. This error is solved when I replace $parameters.MarkerName with any regular text like "var newMarker = ....". 

The problem however is that I want to draw lots of markers and interact with them. For this I need to have separate javascript objects that I can then access and run methods against. 

If it's not possible to create dynamic variable names like this, does anyone then have a different method?

note: $parameter.MarkerName is a Text type variable. 

edit: Just noticed that the error also disappears when I remove the var keyword. Although this will probably work it's against the Mobile Best Practices guide (


The marker logic is already loaded as part of the leaflet script. I'm now trying to create a new javascript variable based on the name specified in a Input variable. This is failing when I use the var keyword and could be a platform issue, could also be not. So I'm looking for experience hoping to find a solution.


I partially solved my issue and that is good enough for now. 

It's a nasty method but it works. I first create a Text object that contains my script. Then I use the javascript function eval() to parse and run the script inside the Text object. I know eval() is slow but my scripts are tiny and still performs excellent.


Hi Vincent,

You shouldn't use the var keyword in this case. The var keyword is used to declare variables but the output parameters are automatically declared by the platform under the scope of that JavaScript node.

If you happen to need some auxiliary variables then you should use the var keyword. For output parameters, you shouldn't.

Happy coding