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

Ivan Grcic ivan.grcic at geofoto.hr
Fri Nov 7 17:56:02 EST 2008


Hey Alex...well actually i didnt catch time to try the patch...but
before patch was made i created dirty hack that was working for me.
Its not the best solution, but hey it works :)

inside drawFeature just add one if statement
 function(feature, style) {
   if (OpenLayers.Util.indexOf(this.features, feature) != -1){
   ...
   ...
}
}

(but for sure I will try the patch supplied in 1806 as soon as i can)

On Fri, Nov 7, 2008 at 8:15 PM, Alexandre Dube <adube at mapgears.com> wrote:
> Answer to my second question...  still looking for the first...
>
>  >> If not, I would like to disable the wheel zoom. How can I do that ?
> oNavCtrl = new OpenLayers.Control.Navigation(
>    { 'zoomWheelEnabled': false});
>
> Alexandre Dube wrote:
>> I tried this small patch but unfortunately the problem persist. Is there
>> a new patch for this issue ( feature stays on screen when zooming with
>> mouse over it with cluster strategy ) ?
>>
>> If not, I would like to disable the wheel zoom. How can I do that ?
>>
>> Alexandre
>>
>> Tim Schaub wrote:
>>
>>> 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
>>>>>
>>>>>
>>>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



-- 
Ivan Grcic



More information about the Dev mailing list