[OpenLayers-Users] Click propagation problem
fooquency
fooquency at gmail.com
Sun Aug 8 11:56:30 EDT 2010
> I wonder if someone could help me out with some pointers or a code
solution
> with this OpenLayers problem I've run into. I've been going round for
hours
> trying to work out what's wrong, and I've not come across an obvious
> solution in the documentation. The working example is
> at http://bit.ly/dcutnD
> What I'm trying to achive is:
> 1) Click on an icon
> 2) The popup comes up
> 3) Click 'Choose this point'. The point will be set as the start location
> and the popup balloon will disappear.
> 4) Now if you click on another icon, the same thing should happen. BUT
> instead, the popup briefly appears, a red icon is set (meaning 'finish')
and
> the popup disappears.
> I thought this might be something to do with stopping click propagation,
> which I see can be done using OpenLayers.Handler.Feature stopClick, or
> presumably stopping an event passing through. But I couldn't work out how
to
> attach those to the SelectFeature. And anyway:
> I don't think it's that because the first of the two clicks works exactly
as
> expected without me having to do anything special coding-wise. Therefore
I'm
> wondering if there is some implicit layer re-selection/activation going
on,
> or something that changes the state, which somehow I have to reset.
> The two key files are photomap.js and itinerary.js.
> Also there is a second issue, whereby the green/red markers appear under
the
> main feature icons. I am, however, setting the zIndex and zIndexing, but
to
> no effect - in the Chrome js inspector, both icon types get z-index=auto
for
> the computed style. Again, any pointers would be helpful. (NB I cannot
> trivially change the code order so that the feature layers are loaded in
the
> other order.)
> Any help would be gratefully received!
>
> Martin
On 3 August 2010 10:15, Pierre wrote:
>
> I suspect something strange happens in the onFeatureUnselect method.
> I added some breakpoints using firebug and things went well which may
> demonstrate that the onFeatureSelect and onFeatureUnselect call has an
> impact.
> I think you're hopping that they are called in a specific order which
> may be wrong.
>
> I cannot easily check this but I would add console.log statements to
> verify that removePopup and addPopup calls are correctly called with
> the correct arguments, that CS.popup is not destroyed just after being
> created.
>
> What I would first suggest is listening to "featureselected" and
> "featureunselected" events instead of onFeatureSelect and
> onFeatureUnselect callbacks.
> This shouldn't radically change things. This is a more modern though.
>
Pierre, thank you very much for your reply. I've migrated the code to using
those event listeners rather than callbacks. (This hasn't fixed the problem
but at least it is a more modern way.) I also believe the popup calls are
being passed the correct values.
A colleague and I have spent many further hours on this, and we still can't
resolve this. Can anyone provide any further suggestions or a solution? -
We're tearing our hair out on this!
By way of reminder the problem is:
http://bit.ly/dcutnD
On first click of an icon, the popup comes up fine, and clicking the box
within it then dismisses the popup and sets the green marker.
Clicking on a second icon then results in the marker being selected and the
popup disappearing.
The itinerary.js file does explicitly specify that the popup should
disappear.
So I *think* what is happening on that second icon scenario is:
1) User clicks on the marker
2) The popup is created
3) The click-through propagates to the itinerary marker layer
4) The itinerary.requestNearestPoint method is called, which firstly
destroys the popup, before the user has had a chance to do anything with it.
My hunch is that either:
a) The phase where the red itinerary marker is being placed somehow changes
the layer status, whatever that is. (After all, this all works correctly for
the first icon.) Or:
b) Somehow we have to stop click propagation.
Neither of us are experts at Javascript, and so any help would be very
highly appreciated.
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100808/2e0d8dd8/attachment.html
More information about the Users
mailing list