On Wed, May 13, 2009 at 11:13:38AM -0400, Stéphane Poirier wrote:
> Hi All (and Tim),
> 
> Catching events using predefined function hook works fine for me (case 2 and 
> 3),
> but I do not have any success catching events using layer.events.register 
> (case
> 4) nor layer.events.on (case 5). What do I do wrong? Should
> layer.events.register and/or layer.events.on be used before the layer is
> created? And what is the difference between these two?
> 
> //1) create layer
> rectangleLayer=new OpenLayers.Layer.Vector("Selection");
> 
> //2) works fine
> rectangleLayer.preFeatureInsert=function(feature)
> {
>       feature_tobeinserted();
> }
> 
> //3) works fine
> rectangleLayer.onFeatureInsert=function(feature)
> {
>       feature_inserted();
> }
> 
> //4) does not seem to catch event
> rectangleLayer.events.register("sketchcomplete",rectangleLayer,
>       function(event){ var feature = event.feature;
>       return (feature.geometry.getArea() > 10); // false to not add
>       });

The order of arguments in this one is wrong: it should be
("sketchcomplete", function(){}). (The rectangleLayer is totally
unneccesary in the given function.) 

> //5) does not seem to catch event
> rectangleLayer.events.on({
>       sketchcomplete: function(event) {
>       var feature = event.feature;
>       return (feature.geometry.getArea() > 10); // false to not add
>       }});
> 
> Regards,
> 
> 
> Stéphane Poirier
> Professionel de recherche au CARTEL
> Centre d'Applications et de Recherches en Télédétection
> Département de géomatique appliquée
> Université de Sherbrooke
> Sherbrooke (Québec), CANADA J1K 2R1
> Tel.: (+1 819) 821 8000 #61904
> Fax.: (+1 819) 821 7944
> [email protected]
> http://www.usherbrooke.ca/cartel
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users

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

Reply via email to