[OpenLayers-Users] Quick eval() question
Tim Schaub
tschaub at opengeo.org
Wed Jul 2 01:35:00 EDT 2008
Hey-
Ian wrote:
> I'm using a javascript object to keep track of the current WMS layer a
> user is querying against:
>
> myObj.query.layer = 'volcanoes';
>
> and am using eval to convert this string back to the layer variable name
> for a getFeatureInfo request:
>
> var queryLyr = eval(window.myObj.query.layer);
>
> but know that using eval() is generally frowned upon and am wondering if
> there is another way to do this?
>>> var volcanoes = {name: "foo"};
>>> window['volcanoes'].name
"foo"
You also could have myObj.query.layer reference the object itself
>>> myObj = {query: {layer: volcanoes}};
>>> myObj.query.layer.name
"foo"
Tim
> Thank you.
> !DSPAM:4033,486a8cc0114993327367457!
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
> !DSPAM:4033,486a8cc0114993327367457!
More information about the Users
mailing list