[OpenLayers-Users] SelectFeature
Stefano Bonnin
stefano.bonnin at comai.to
Thu Oct 11 05:54:08 EDT 2007
Lourens Veen ha scritto:
> 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
>
>
I have written an initial possible solution. The code is very confused
but it works. With this solution you can add polygon and lines to the
layers and after do the select.
It use a pointinsidepolygon and lineDistance algorithms ...
The code can be useful for people that, like me, have to select features
from different layers ...
Red Shaphiro
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: oldemo.php
Url: http://openlayers.org/pipermail/users/attachments/20071011/6ee5be3d/attachment-0001.diff
More information about the Users
mailing list