OpenLayers – Accessing Feature using `featureadded` Event.

By | January 14, 2013

We might need to alter a feature or to extract a particular attributes upon feature added to the layer. So we need to register an event named `featureadded` for the target layer.

function newVectorLayer(name, option)
{
	var n = new OpenLayers.Layer.Vector(name, option);
	n.events.register('featureadded', null, function (e)
	{
		// do something
	}
	);
	return n;
}

p/s: use `featuresadded` if you need to access when all features are added.

Leave a Reply

Your email address will not be published. Required fields are marked *

four × two =