[OpenLayers-Users] Way to get name of the feature attribute?

paweluz paweluz at o2.pl
Fri Jan 22 06:38:47 EST 2010


Hi

I am using WFS-T to add object to the database. Is there a way to get a name
of columns in that database. I mean how to get the name of the attribute. I
am using these code below to add new object to the database.

     drawControls = {
               	add_object:new OpenLayers.Control.DrawFeature(
                    zielona_wfs, OpenLayers.Handler.Path
                )}


	drawControls["add_object"].featureAdded = function(feature) {
                feature.layer.eraseFeatures([feature]);
                feature.geometry = new OpenLayers.Geometry.MultiLineString(
                    feature.geometry
                );
		selectedfeature=feature;
                feature.state = OpenLayers.State.INSERT;
                feature.layer.drawFeature(feature);
            } 

.............................

		function add_object() {		
			selectedfeature.attributes['Id']  
=parseInt(document.getElementById("id_geometry").value);
			selectedfeature.attributes['Road'] =
document.getElementById("road_geometry").value;
			map.layers[1].commit();
			return false;
		}



As you can see I am using selectedfeature.attributes['Id']. I would like to
use instead of 'Id' some parameter of feature or wfs layer (zielona_wfs). Is
they a way to get to name of attributes (column in database) through WFS
layer. I would also like to say that this:

			var object_attributes = feature.attributes
                        for (var key in object_attributes)
			{
				document.write(key);
			}	


will not work because object_attributes is empty (because I am adding new
object to database, not editing existing one)

Does anyone have any idea??

Thanks,
Poul


-- 
View this message in context: http://n2.nabble.com/Way-to-get-name-of-the-feature-attribute-tp4439540p4439540.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list