<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> </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> {isBaseLayer: false,<BR> styleMap: style_gate, <BR> extractAttributes: true });<BR>maingatewfs.addFeatures(mgfeat);<BR>map.addLayer(maingatewfs);</DIV>
<DIV><BR>Robert Sanson<BR>>>> "Sveen Atle Frenvik (Geomatikk IKT)" <Atle.Frenvik.Sveen@geomatikk.no> 9/03/2010 1:32 a.m. >>><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> - fetch x and y<BR> - create an OpenLayers Geometry<BR> - create a OpenLayers Vector feature<BR> - 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 contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this 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>