<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-1>
<META content="MSHTML 6.00.6002.18255" name=GENERATOR></HEAD>
<BODY id=MailContainerBody 
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" leftMargin=0 
topMargin=0 CanvasTabStop="true" name="Compose message area">
<DIV><FONT face=Arial size=2>The comment about it not being a good place to 
change properties was at the individual feature adding part of the 
cycle.</FONT></DIV>
<DIV><FONT face=Arial size=2>Changing properties before features are added is 
perfectly fine, however, you are right that it would be even better to make the 
layers from the metadata and then add features.</FONT></DIV>
<DIV><FONT face=Arial size=2>Just use an OpenLayers.Request and process the 
response in the callback function.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Matt Priour</FONT></DIV>
<DIV><FONT face=Arial size=2>Kestrel Computer Consulting</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=tonidelacalle@gmail.com 
href="mailto:tonidelacalle@gmail.com">toni hernández</A> </DIV>
<DIV><B>Sent:</B> Wednesday, July 21, 2010 1:38 AM</DIV>
<DIV><B>To:</B> <A title=mpriour@kestrelcomputer.com 
href="mailto:mpriour@kestrelcomputer.com">Matt Priour</A> </DIV>
<DIV><B>Cc:</B> <A title=dev@openlayers.org 
href="mailto:dev@openlayers.org">dev@openlayers.org</A> </DIV>
<DIV><B>Subject:</B> Re: [OpenLayers-Dev] Metadata inside a 
JSON</DIV></DIV></DIV>
<DIV><BR></DIV>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&nbsp; 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>&lt;<A 
title="mailto:mpriour@kestrelcomputer.com&#10;CTRL + Click to follow link" 
href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
  <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&nbsp;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>&nbsp;</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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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 &lt;</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>&gt;<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></BODY></HTML>