[OpenLayers-Users] Limit total Vector Layer points to be drawn

giraam sdjbm17 at gmail.com
Mon Jul 12 09:40:21 EDT 2010


Hi people,

I'm trying to limit the total Vector Layer's point to be drawn.. For
example, after one point has been drawn prevent new points to be added..

I tried registering beforefeatureadded event as the definition for this
event says:

Triggered before a feature is added.  Listeners will receive an object with
a feature property referencing the feature to be added.  To stop the feature
from being added, a listener should return false.

My code:

    vectorLayer.events.register('beforefeatureadded', this,
function(feature){
        if(vectorLayer.features.length = 1){
            alert("false "+vectorLayer.features.length);
            return false;
        }else{
            alert("true "+vectorLayer.features.length);
            return true;
        }
    });

But even if I return false, the feature is added to the layer! :S

Any suggestion, please?

Thanks in advance!

Gilberto Ramos

-----
just another web developer
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-total-Vector-Layer-points-to-be-drawn-tp5282918p5282918.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list