[Mapbender-dev] Re: [Mapbender] #120: replace ["..."] with dot
notation in JS
Marc Jansen
jansen.marc at gmx.de
Tue Oct 16 09:47:49 EDT 2007
Hi Christoph,
I thought that the root of the failure might be the (IMHO) incorrect
usage of arrays in Javascript. Correct me if I'm but AFAIK there are no
associative arrays within javascript. The purpose of these are handles
by objects. I know that object have some disadvantages -- e.g. they are
missing the length property.
I personally favor the bracketed syntax, but thats a sole personal
preference.
-- Marc
Christoph Baudson (WhereGroup) schrieb:
> Sorry for the last post. Ignore it. Too much copy and paste for any
> human to handle. Here's the version I intended to post
>
> --
>
> To illustrate the difference, an example
>
> Does not work with toJSONString()
>
> currentLayer.layer_style[count] = [];
> currentLayer.layer_style[count]["name"] = styleName;
> currentLayer.layer_style[count]["title"] = styleTitle;
> currentLayer.layer_style[count]["legendurl"] = styleLegendUrl;
> currentLayer.layer_style[count]["legendurlformat"] =
> styleLegendUrlFormat;
>
> Does work
>
> currentLayer.layer_style[count] = {};
> currentLayer.layer_style[count].name = styleName;
> currentLayer.layer_style[count].title = styleTitle;
> currentLayer.layer_style[count].legendurl = styleLegendUrl;
> currentLayer.layer_style[count].legendurlformat =
> styleLegendUrlFormat;
>
> May work, not tried (curly brackets in line 1)
>
> currentLayer.layer_style[count] = {};
> currentLayer.layer_style[count]["name"] = styleName;
> currentLayer.layer_style[count]["title"] = styleTitle;
> currentLayer.layer_style[count]["legendurl"] = styleLegendUrl;
> currentLayer.layer_style[count]["legendurlformat"] =
> styleLegendUrlFormat;
> _______________________________________________
> Mapbender_dev mailing list
> Mapbender_dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapbender_dev
>
More information about the Mapbender_dev
mailing list