[OpenLayers-Users] SelectFeature
Lourens Veen
veen at science.uva.nl
Tue Oct 9 12:44:13 EDT 2007
On Tuesday 09 October 2007 14:10:49 Christopher Schmidt wrote:
> On Tue, Oct 09, 2007 at 01:24:27PM +0200, Stefano Bonnin wrote:
> > hi all,
> >
> > I have to define a popup for every vector feature but I notice that
> > SelectFeature has some problem when there is more than 1 layer. The
> > SelectFeature control seems to work only when there is 1 layer
> > active. This (critical, for me) SelectFeature bug will be pathed
> > only in the 2.6 release of OpenLayers ... so ...
>
> Actually, it's not expected, as far as I know, to be fixed then
> either. (It might be, with some recent work we're doing, but it's not
> high on the priority list). This is a limitation of browser event
> handling with SVG.
The same limitation causes trouble if you have multiple features on top
of each other in the same layer. The browser will render them in some
order, and one of them will end up on top. That one can then be
selected, but the other ones can't be.
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.
Also, you still have no intuitive way of selecting only a small polygon
lying completely inside a larger one: you have to select both of them
first by clicking inside the small one, and then deselect the large one
by clicking somewhere inside it where the small one is not.
Another possibility I'm considering trying is to use the Box handler,
and then only select a feature if one (all?) point is within the
dragged box.
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