[OpenLayers-Users] SelectFeature
staff-gmail
john.staff2222 at gmail.com
Tue Oct 9 13:57:13 EDT 2007
Stephen Woodbridge wrote:
> Lourens Veen wrote:
>
>> 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,
>
> 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?
>
> 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?
>
> -Steve
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
Selection by lat/lon can be done by using a point in polygon algorithm
which we've found to be pretty fast (it is in java and c++, we'll see in
Ruby). Using this selection method allows you to specify which object
groups you're testing on which means you can filter down the search
space and avoid the "layers" problem. ps: it might even be faster if
you treat the lat/long as integers but I'm not sure of the speed vs
hassle tradeoff.
And if you name your svg element id's with the database id's, then your
lat/long lookup can be translated back to a DOM operation, if that makes
any sense.
More information about the Users
mailing list