<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>Hi Josh</DIV>
<DIV> </DIV>
<DIV>I have a web site that reads in JSON to create a layer of crops. This layer can be modified. I then write out the geometry of the selected features. Here are the code snippets:</DIV>
<DIV> </DIV>
<DIV>//declare the format</DIV>
<DIV>var geojson_format = new OpenLayers.Format.GeoJSON();</DIV>
<DIV> </DIV>
<DIV>//add the layer</DIV>
<DIV>crops = new OpenLayers.Layer.Vector("Crop areas",<BR> {isBaseLayer: false,<BR> style: crop_style, <BR> extractAttributes: true }); <BR> crops.addFeatures(geojson_format.read(cropsresponse.responseText));</DIV>
<DIV>map.addLayer(crops);<BR>map.zoomToExtent(crops.getDataExtent());</DIV>
<DIV> </DIV>
<DIV>//Select, Draw and Modify controls - these are specific to the layer</DIV>
<DIV>controls = {<BR> select: new OpenLayers.Control.SelectFeature(crops, {callbacks: {'over':feature_info}}),<BR> dpolygon: new OpenLayers.Control.DrawFeature(crops,OpenLayers.Handler.Polygon),<BR> modify: new OpenLayers.Control.ModifyFeature(crops),<BR> delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {crops.destroyFeatures([feature])}})<BR> //delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {feature.geometry.destroy();crops.eraseFeatures([feature])}})<BR> };<BR> for(var key in controls) {<BR> map.addControl(controls[key]);<BR> }<BR> }</DIV>
<DIV> </DIV>
<DIV>//write out the geometry into a div</DIV>
<DIV>function feature_info(feature) {<BR> var html = "<ul>";<BR> OpenLayers.Util.getElement('crop').innerHTML = "<strong>ID:</strong>" + feature.attributes.prop0 + " <strong>Area:</strong>" + (Math.round(feature.geometry.getArea() / 100) / 100).toString() + " Ha";<BR> var json = geojson_format.write(feature);<BR> json = json.replace(/,/g, ', ');<BR> document.getElementById('comments').innerHTML = json;<BR> }<BR></DIV>
<DIV>Hope that gives you some starters.</DIV>
<DIV> </DIV>
<DIV>regards,</DIV>
<DIV> </DIV>
<DIV>Robert S. </DIV>
<DIV><BR>>>> "Josh S." <jstreufe@utk.edu> 23/05/2009 5:07 a.m. >>><BR><BR>I need to export the geometries of multiple polygons a user draws, my plan is<BR>to use json to export the geometries to another .js I'm using. Any<BR>tips/help/code would be great.<BR><BR>-Josh<BR>-- <BR>View this message in context: <A href="http://n2.nabble.com/Draw">http://n2.nabble.com/Draw</A>-Polygons-and-Export-Geometry-tp2958594p2958594.html<BR>Sent from the OpenLayers Users mailing list archive at Nabble.com.<BR><BR>_______________________________________________<BR>Users mailing list<BR>Users@openlayers.org<BR><A href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</A><BR><BR></DIV><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>