<HTML><HEAD><TITLE>Re: [OpenLayers-Users] Make vector layer from JSON</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY>
<DIV>Thanks Atle - this is what is working for me from the returned JSON:</DIV>
<DIV>&nbsp;</DIV>
<DIV>var myObject = JSON.parse(response.responseText); //JSON.parse is a parser based on json2.js</DIV>
<DIV>var x_nztm = (+myObject.results[0].attributes.x_nztm);<BR>var y_nztm = (+myObject.results[0].attributes.y_nztm);<BR>var mggeom = new OpenLayers.Geometry.Point(x_nztm,y_nztm);<BR>var mgfeat = new OpenLayers.Feature.Vector(mggeom);<BR>mgfeat.attributes.farm_id = myObject.results[0].attributes.farm_id;<BR>mgfeat.attributes.rapid_no = myObject.results[0].attributes.rapid_no;</DIV>
<DIV>mgfeat.attributes.road_name = myObject.results[0].attributes.road_name;<BR>mgfeat.attributes.locality = myObject.results[0].attributes.locality;</DIV>
<DIV>var maingatewfs = new OpenLayers.Layer.Vector("Main Gate 2",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{isBaseLayer: false,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;styleMap: style_gate,&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extractAttributes: true });<BR>maingatewfs.addFeatures(mgfeat);<BR>map.addLayer(maingatewfs);</DIV>
<DIV><BR>Robert Sanson<BR>&gt;&gt;&gt; "Sveen Atle Frenvik (Geomatikk IKT)" &lt;Atle.Frenvik.Sveen@geomatikk.no&gt; 9/03/2010 1:32 a.m. &gt;&gt;&gt;<BR></DIV><!-- Converted from text/plain format -->
<P><FONT size=2>As long as you are able to parse the data, putting them on the map is a<BR>no-brainer, pseudo-code something like:<BR><BR>for each feature<BR>&nbsp;&nbsp;&nbsp;&nbsp; - fetch x and y<BR>&nbsp;&nbsp;&nbsp;&nbsp; - create an OpenLayers Geometry<BR>&nbsp;&nbsp;&nbsp;&nbsp; - create a OpenLayers Vector feature<BR>&nbsp;&nbsp;&nbsp;&nbsp; - add attributes to feature if required<BR><BR>then add features to a layer<BR><BR>-atle<BR><BR></FONT></P><br><br><table bgcolor=white style="color:black"><tr><td><br>------------------------------------------------------------------<br>
The&nbsp;contents&nbsp;of&nbsp;this&nbsp;email&nbsp;are&nbsp;confidential&nbsp;to&nbsp;AsureQuality.&nbsp;If&nbsp;you&nbsp;have&nbsp;received&nbsp;this&nbsp;communication&nbsp;in&nbsp;error&nbsp;please&nbsp;notify&nbsp;the&nbsp;sender&nbsp;immediately&nbsp;and&nbsp;delete&nbsp;the&nbsp;message&nbsp;and&nbsp;any&nbsp;attachments.&nbsp;The&nbsp;opinions&nbsp;expressed&nbsp;in&nbsp;this&nbsp;email&nbsp;are&nbsp;not&nbsp;necessarily&nbsp;those&nbsp;of&nbsp;AsureQuality.&nbsp;This&nbsp;message&nbsp;has&nbsp;been&nbsp;scanned&nbsp;for&nbsp;known&nbsp;viruses&nbsp;before&nbsp;delivery.&nbsp;AsureQuality&nbsp;supports&nbsp;the&nbsp;Unsolicited&nbsp;Electronic&nbsp;Messages&nbsp;Act&nbsp;2007.&nbsp;If&nbsp;you&nbsp;do&nbsp;not&nbsp;wish&nbsp;to&nbsp;receive&nbsp;similar&nbsp;communications&nbsp;in&nbsp;future,&nbsp;please&nbsp;notify&nbsp;the&nbsp;sender&nbsp;of&nbsp;this&nbsp;message.<br>
------------------------------------------------------------------</td></tr></table><br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for malware by SurfControl plc.  </FONT><A href="http://www.surfcontrol.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.surfcontrol.com</FONT></A></P>
</body></HTML>