[OpenLayers-Users] How to use layer.events.register() and
layer.events.on()?
Stéphane Poirier
Stephane.Poirier at USherbrooke.CA
Wed May 13 11:13:38 EDT 2009
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
});
//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
Stephane.Poirier at USherbrooke.ca
http://www.usherbrooke.ca/cartel
More information about the Users
mailing list