<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>You can use JavaScipt code to remove existing layers and add new ones, based on user interaction.</DIV>
<DIV> </DIV>
<DIV>For example, if you had a function that called a URL that returned some JSON data, you could turn it into a new layer:</DIV>
<DIV> </DIV>
<DIV>function othptsreturn(response) {<BR> if (response.responseText.indexOf('missing') != -1) {<BR> }<BR> else {</DIV>
<DIV> var json_format = new OpenLayers.Format.JSON();<BR> var oFeatures = json_format.read(response.responseText); <BR> var othptsl = new OpenLayers.Layer.Vector("Other Points",<BR> {isBaseLayer: false,<BR> styleMap: othStyles, <BR> extractAttributes: true });<BR> othptsl.addFeatures(oFeatures);<BR> map.addLayer(othptsl);<BR> }<BR> }</DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV><BR>Robert<BR><BR>>>> Vikash Talanki <vikashtalanki@gmail.com> 8/06/2011 4:27 p.m. >>><BR>Does this suffice adding of a new layer?? adding a point to existing layer is<BR>trivial but adding a new layer itself need to put its specific code in JS. <BR><BR>Let me explain with an example, suppose my map already has 3 layers. Now if<BR>the user wants to add 4th layer then I can provide him a form to fill the<BR>data and store these 4th layers details/data in a text file/db through a php<BR>script. Up to here everything is fine, but now someone has to add this layer<BR>to JS so that the user can see it as soon as he reload the page. <BR><BR><BR><BR>--<BR>View this message in context: <A href="http://osgeo">http://osgeo</A>-org.1803224.n2.nabble.com/Automatic-updation-of-OpenLayers-code-tp6452157p6452308.html<BR>Sent from the OpenLayers Users mailing list archive at Nabble.com.<BR>_______________________________________________<BR>Users mailing list<BR>Users@lists.osgeo.org<BR><A href="http://lists.osgeo.org/mailman/listinfo/openlayers">http://lists.osgeo.org/mailman/listinfo/openlayers</A>-users<BR></DIV><br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.</FONT></P>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for Malware and Viruses by Websense Hosted Security. </FONT><A href="http://www.websense.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.websense.com</FONT></A></P>
</body></HTML>