[OpenLayers-Users] SelectFeature

Lourens Veen veen at science.uva.nl
Tue Oct 9 15:24:56 EDT 2007


On Tuesday 09 October 2007 19:17:53 Stephen Woodbridge wrote:
> Lourens Veen wrote:
> >
> > The problem is that the event handler uses the source of the event,
> > as passed by the browser in the Event object, to determine which
> > feature was clicked. The browser chooses one feature to attach the
> > event to, and so only one feature can be selected.
> >
> > The solution to this is to find out where the user clicked,
> > transform the screen coordinates into LatLon, and then search
> > through the features to find out which features are at that
> > location. It's not very fast, but it works. The problem is that
> > selection isn't precise, because OpenLayers.Geometry.atPoint() uses
> > a bounding box test (and I've got polygons in my WFS layer). That
> > would be quite hard to fix.
> >
>
> Lourens,
>
> Another idea that might work it to take the item attached to the
> event and hide it, then re-issue the event and see if you get another
> object, and continue until you do not get an object. I'm not sure if
> this is possible, but it would allow you to collect the objects into
> an array which could be returned. You might want to differentiate
> single-select from multiple-select?

I thought of that, but unfortunately, there's no way of reissuing the 
event without having an element to reissue it on. In other words, to 
solving the problem this way requires knowing the solution already.

Normal HTML event bubbling won't work either: events bubble up the DOM 
hierarchy, but that isn't related to the spatial distribution of the 
features in any way.

> Also isn't there a way to allow an event to propagate to other layers
> below the one currently being handled. If this happened would you not
> get a series of events for all the overlapping features?

Not that I have been able to find. Perhaps a new event model is in order 
now that browsers support SVG, and more complex applications are 
written. But that's not going to help us now.

Lourens

-- 
          ir. Lourens Veen          University of Amsterdam - IBED
                                    Nieuwe Achtergracht 166
    Scientific Software Engineer    1018 WV Amsterdam, The Netherlands
             EcoGRID-GAN            t: +31 20-5257453  f: +31 20-5257431



More information about the Users mailing list