Thanks Matt,<br><br>I have been thinking about your solution. I could work but as you said "is not a good place/time to be changing layer properties". So I kept on thinking... and now I am wondering. <br><br>Wouldn't it be better to do an ajax call to web-service, then eval the ajax response with all the information about style, about features and everything and then create each layer with the proper style, features and everything?.<br>
<br>What do you think?<br><br><br><br><div class="gmail_quote">2010/7/20 Matt Priour <span dir="ltr"><<a href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="padding-right: 10px; padding-left: 10px; padding-top: 15px;" name="Compose message area">
<div><font face="Arial" size="2">Toni,</font></div>
<div><font face="Arial" size="2">I am assuming you are using an
OpenLayers.Layer.Vector layer with an HTTP protocol.</font></div>
<div><font face="Arial" size="2">You need to add a listener for
'beforefeaturesadded' event on the layer.</font></div>
<div><font face="Arial" size="2">The original JSON should be cached in the event
object as well as the parsed features.</font></div>
<div><font face="Arial" size="2">You want to apply the layer configuration metadata
properities to the layer in the 'beforefeaturesadded' event
handler.</font></div>
<div><font face="Arial" size="2">be sure to use 'beforefeaturesadded' with the
plural featureS rather than the 'beforefeatureadded' event with the singular
feature</font></div>
<div><font face="Arial" size="2">The plural features event runs once before any
features are added from each response, while the singular feature runs
before each individual feature is added and the original JSON response will NOT
be available. Also that is not a good place/time to be changing layer properties
anyway.</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">Matt Priour</font></div>
<div><font face="Arial" size="2">Kestrel Computer Consulting</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">IN REPLY TO:</font></div>
<div><font face="Arial" size="2"><font face="Arial" size="2">------------------------------------------------------------------------------------</font></font></div>
<div><font face="Arial" size="2"><font face="Times New Roman" size="3">Date: Tue, 20
Jul 2010 17:31:14 +0200<br>From: toni hern?ndez <</font><a href="mailto:tonidelacalle@gmail.com" target="_blank"><font face="Times New Roman" size="3">tonidelacalle@gmail.com</font></a><font face="Times New Roman" size="3">><br>
Subject: [OpenLayers-Dev] Metadata inside a
JSON</font><br></font></div><div><div></div><div class="h5">
<div>hi all,<br><br>I have a map with lots of layers. Each layer has its own
style. The map<br>application gets each layer from a web-service that some else
has developed<br>and can not be modified (I guess).<br><br>I thouht I could put
any kind of data in a json file, so I tried this:<br><br>{<br>"type":
"FeatureCollection",<br>"name": "Mapa de la
Internacionalitat",<br>"minScale":"whatever",<br>"maxScale":"whatever",<br><br>//and
then features and its properties?<br>"features": [<br>...<br>]<br>}<br><br>Now I
have realized that atributes "name", "minScale" and "maxScale" are
not<br>available from the layer object. I can only get the features
properties.<br><br>Is it possible to read first the data of the layer, then
create the layer<br>and finally add the features?<br>How could / should I do
that?<br><br>Thanks in advance.</div></div></div></div>
</blockquote></div><br>