Roald de Wit wrote: > On Wed, 2007-09-19 at 21:32 -0400, Robert J Becraft wrote: > >> This example has the draw polygon feature... How can you capture the >> polygons that are drawn and save them for future use and retrieval? >> >> http://www.openlayers.org/dev/examples/select-feature.html >> >> > > Hi Robert, > > This example might help you: > http://www.openlayers.org/dev/examples/gml-serialize.html > > Regards, > > Roald > > O.K. I added the code to be able to add polygons to the example... It created the following output...
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"><gml:featureMember xmlns:gml="http://www.opengis.net/gml"><feature:features xmlns:feature="http://mapserver.gis.umn.edu/mapserver" fid="OpenLayers.Feature.Vector_199"><feature:geometry><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">11.6015625,0.703125 29.70703125,0.87890625 29.53125,-7.734375 12.12890625,-7.734375 11.6015625,0.703125</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></feature:geometry><feature:name>ddddddd</feature:name></feature:features></gml:featureMember><gml:featureMember xmlns:gml="http://www.opengis.net/gml"><feature:features xmlns:feature="http://mapserver.gis.umn.edu/mapserver" fid="OpenLayers.Feature.Vector_228"><feature:geometry><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">15.8203125,17.9296875 24.43359375,20.0390625 21.4453125,25.83984375 18.6328125,24.9609375 19.16015625,21.97265625 17.05078125,21.26953125 14.23828125,23.73046875 12.3046875,21.4453125 12.3046875,18.6328125 15.8203125,17.9296875</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></feature:geometry><feature:name>dfdfdfdfdf</feature:name></feature:features></gml:featureMember></wfs:FeatureCollection> It came out of this code... function serialize(feature) { feature.attributes = {}; var name = prompt("Name for feature?"); feature.attributes['name'] = name; var data = g.write(feature.layer.features); OpenLayers.Util.getElement("gml").value = data; trace.innerHTML=feature.layer.features; } The last line I added only generates [object Object],[object Object]. I was looking for g.write and can't find that to see what it is looking at to generate the data in the variable "data". How do I use this in order to save and put these polygons back into the polygon layer??? Honestly, I don't know what this object is that I'm looking at. My goal is to dynamically generate the polygon from other code I've already written and insert it into the polygon layer. Then when the cursor is hovered over the polygon, I can display data associated with the polygon. Thanks, Robert J Becraft. _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
