[OpenLayers-Dev] Bug in rendering features with cluster strategy

Eric Lemoine eric.c2c at gmail.com
Tue Nov 4 00:50:13 EST 2008


Tim, what about this case: feature is selected then is *removed* from
the layer.  Eventually the feature handler triggers "mouseout", which
makes the select feature control call drawFeature for a feature which
isn't in the layer. Eric

2008/11/4, Tim Schaub <tschaub at opengeo.org>:
> Hey-
>
> Eric Lemoine wrote:
>> Yes. Especially since drawFeature is often called from addFeatures,
>> where we're assured that the feature is in the layer. So, instead, we
>> may want to change the select feature control so that it calls
>> drawFeature only if, in the case of selection, the feature is in the
>> "features" array, and in the case of unselection, the feature is in
>> the "selectedFeatures" array. What do you think? Eric
>>
>
> The problem is in the Feature handler.  We destroy features, but
> references to them are still truthy.  Since the destroy code sets the
> layer property to null, one check of an undestroyed feature is to check
> feature.layer.
>
> See http://trac.openlayers.org/attachment/ticket/1806/destroyed.patch
>
>> 2008/11/4, Tim Schaub <tschaub at opengeo.org>:
>>> Hey-
>>>
>>> Ivan Grcic wrote:
>>>> OK... i found it..inside Layer.Vector...now the question is: should i
>>>> put something like this:
>>>>
>>>> if (OpenLayers.Util.indexOf(this.features, feature) != -1){
>>>>
>>>> inside drawFeature: function(feature, style) {
>>> Nope.  Making drawFeature that safe at the expense of iterating through
>>> every feature with every draw is a mistake.
>>>
>>>> or inside every other function inside Layer.Vector that uses
>>>> drawFeature function?
>>>>
>>>> When I put it here:
>>>>
>>>>     drawFeature: function(feature, style) {
>>>> -->	if (OpenLayers.Util.indexOf(this.features, feature) != -1){
>>>> ..
>>>> ..
>>>>      }
>>>> }
>>>>
>>>> it works pretty fine for me :) Eric?
>>>>
>>>> On Mon, Nov 3, 2008 at 9:53 AM, Ivan Grcic <ivan.grcic at geofoto.hr>
>>>> wrote:
>>>>> Yup, its not Cluster Strategy...
>>>>> http://trac.openlayers.org/ticket/1806#comment:2
>>>>>
>>>>> On Mon, Nov 3, 2008 at 9:11 AM, Eric Lemoine <eric.c2c at gmail.com>
>>>>> wrote:
>>>>>> Hi.
>>>>>>
>>>>>> Yes, this looks like a bug in OpenLayers.
>>>>>>
>>>>>> I'm under the impression that this isn't a bug in the cluster strategy
>>>>>> but either in Layer.Vector or in Control.SelectFeature. Indeed, I
>>>>>> think SelectFeature calls layer.drawFeature on feature
>>>>>> selection/unselection without checking whether the feature is in the
>>>>>> layer. And i'm saying this may be a bug in Layer.Vector because it may
>>>>>> be that drawFeature should be responsible for checking whether the
>>>>>> feature is in the layer before actually drawing it.
>>>>>>
>>>>>> This is just coming from the top of my head so i may be wrong, but i'm
>>>>>> feeling this is a good track to follow :)
>>>>>>
>>>>>> Eric
>>>>>>
>>>>>> 2008/11/2, Ivan Grcic <ivan.grcic at geofoto.hr>:
>>>>>>> Hi list,
>>>>>>>
>>>>>>> i discovered a bug while developing my OL application, in cluster
>>>>>>> strategy class.
>>>>>>>
>>>>>>> Bug occurs when you hover over one feature that represent a cluster
>>>>>>> (or externalGraphic or like in cluster example - vector circle
>>>>>>> http://openlayers.org/dev/examples/strategy-cluster.html)
>>>>>>>
>>>>>>> When you zoom in/out while that feature-cluster is selected (by
>>>>>>> quickly double-clicking or easier using scroll on ur mouse), on next
>>>>>>> zoom that cluster is rendered (stays on screen) together with newly
>>>>>>> created clusters! And clearly it shouldnt be there. The old
>>>>>>> ("phantom") cluster is not selectable, as he doesnt exist on the new
>>>>>>> zoom level..he just stays there on screen...annoying me :)
>>>>>>>
>>>>>>> As you zoom in again and again, phantom clusters always render,
>>>>>>> always
>>>>>>> at the same position in the map div...
>>>>>>>
>>>>>>> Please confirm that this is a bug, im going crazy here with this one
>>>>>>> :|
>>>>>>>
>>>>>>> --
>>>>>>> Ivan Grcic
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> Dev at openlayers.org
>>>>>>> http://openlayers.org/mailman/listinfo/dev
>>>>>>>
>>>>>
>>>>> --
>>>>> Ivan Grcic
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Tim Schaub
>>> OpenGeo - http://opengeo.org
>>> Expert service straight from the developers.
>>> _______________________________________________
>>> Dev mailing list
>>> Dev at openlayers.org
>>> http://openlayers.org/mailman/listinfo/dev
>>>
>
>
> --
> Tim Schaub
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



More information about the Dev mailing list