[OpenLayers-Users] howto regist. featuremodified instead onModification ?

Alexandre Dube adube at mapgears.com
Fri Dec 12 14:19:03 EST 2008


Well, I don't 100% understand.  Using on, what's the use of the scope ?  
The following works without scope :

        olWFSRoads.events.on({
            featuremodified: function(o) {
                var oFeature = o.feature;
                OpenLayers.Console.log("modified", oFeature.id);
            }
        });


or the following works also, but scope is still useless here.

        olWFSRoads.events.on({
            featuremodified: function(o) {
                onRoadModification(o.feature);
            },
            scope: this
        });

function onRoadModification(object) {
    var oFeature = object.feature;
    OpenLayers.Console.log("modified", oFeature.id);
};


In the end, I want to move my OpenLayers demo into MapFish and I want to 
use some widgets like the list of features which uses a Modification 
control.  It already has its own defined onModification function, so I 
have to get rid of mine and register an event instead.  Using one of the 
above method should do the trick, I am correct ?

Thanks again for your help,

Alexandre


Eric Lemoine wrote:
> You are correct.
>
> For information, the second argument to the register method is the
> scope. "this" in the callback will reference the object this scope
> references. Hope I'm clear enough.
>
> Note that can also use the "on" method:
>
> layer.events.on({
>     featuremodified: function(o) {
>     },
>    scope: your_scope
> });
>
> Cheers,
>
> Eric
>
> 2008/12/12, Alexandre Dube <adube at mapgears.com>:
>   
>> Hi,
>>
>>   The onModification function of ModifyControl is deprecated.  How do
>> you register a featuremodified instead ?
>>
>>   I've tried this but oFeature is the layer object instead of a feature :
>>
>>
>> layer.events.register("featuremodified",'', onRoadModification);
>>
>> function onRoadModification(oFeature) {
>>     OpenLayers.Console.log("modified", oFeature.id);
>> };
>>
>>
>> I tried ("featuremodified",this.feature, onRoadModification), not
>> working either.
>>
>> this could work, but I'm not sure it's the good way to do it.
>> function onRoadModification(object) {
>>     oFeature = object.feature;
>>     OpenLayers.Console.log("modified", oFeature.id);
>> };
>>
>> The old onModification was called with (object.feature), so I suppose
>> the above solution is the good way, but I just want to be sure.
>>
>> Any hint ?
>>
>> --
>> Alexandre Dubé
>> Mapgears
>> www.mapgears.com
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>     


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list