[OpenLayers-Dev] callback for setfeature event of TransformFeature Control receives wrong event type

lissabon at online.de lissabon at online.de
Thu Apr 28 12:09:03 EDT 2011


Hi Andreas,

I don't think my issue concerns #2714 (http://trac.osgeo.org/openlayers/ticket/2714 http://trac.osgeo.org/openlayers/ticket/2714 ).
It's the event object which is possibly malformed. I'll try to explain:

Following console.log line..:
OpenLayers.Console.warn("report method received event: " + event.type, event.feature ? event.feature.id : event.components);

..logs following information when I click on a Feature to be set for transformation (please see the 2nd line, which should be "setfeature" instead of "beforesetfeature"):
report method received event: beforesetfeature OpenLayers.Feature.Vector_1081
report method received event: beforesetfeature OpenLayers.Feature.Vector_1081
(First, the click initializes a beforesetfeature event and then instantly a setfeature event.)
It's the property "event.type" of the setfeature event of the TransformFeature callback function, which has the "wrong event information" I meant.

You can investigate this issue if you modify http://openlayers.org/dev/examples/transform-feature.html as following:
Place this into line 8 before OpenLayers library:
<script src="http://www.openlayers.org/api/lib/Firebug/firebug.js"></script>

Place these event registrations into line 52 after the TransformFeature control is initialized:
control.events.register("beforesetfeature", null, function(event) {
 OpenLayers.Console.log("report method received event: " + event.type, event.feature ? event.feature.id : event.components);
 OpenLayers.Console.log(event);
});
control.events.register("setfeature", null, function(event) {
 OpenLayers.Console.warn("report method received event: " + event.type, event.feature ? event.feature.id : event.components);
 OpenLayers.Console.warn(event);
});

Thanks
João


On Apr 28, 2011, at 17:24 , Andreas Hocevar wrote:

Looking more closely, I see that #2714 was about the transformcomplete event.

What exactly do you mean by "wrong event type"? Both the "beforesetfeature" and "setfeature" event are called with an object that contains a feature.

Andreas.

On Apr 28, 2011, at 17:16 , Andreas Hocevar wrote:

> This issue has been fixed in trunk, and will be included in the upcoming 2.11 release. See http://trac.osgeo.org/openlayers/ticket/2714 http://trac.osgeo.org/openlayers/ticket/2714 
> 
> Andreas.
> 
> On Apr 28, 2011, at 16:55 , João wrote:
> 
>> 
>> It seems like the callback for the "setfeature" event of OpenLayers.Control.TransformFeature receives the wrong event type "beforesetfeature"!
>> 
>> (Somehow the correct callback for setfeature event will be called, but the event object passed to this callback method has the wrong event type.)
>> 
>> Thanks
>> João


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20110428/d0a035b5/attachment.html


More information about the Dev mailing list