Thanks Robert!

I'm looking at it right now, seems to make sense, I'll try to get the pieces
to work on my end.

I'll let you know how it goes.

-Josh

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

-- 
View this message in context: 
http://n2.nabble.com/Draw-Polygons-and-Export-Geometry-tp2958594p2967691.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to