Selecting features on multiple layers

View: New views
3 Messages — Rating Filter:   Alert me  

Selecting features on multiple layers

by Antti Nieminen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I've worked a bit with the feature event issue for multiple layers,
described in ticket #434.
http://trac.openlayers.org/ticket/434

I did pretty much what crschmidt suggested in the ticket. I modified
SelectFeature and Handler.Feature to accept a list of layers instead
of a single layer. Now, when the handler receives an event, it creates
a small square-shaped geometry with its center at mouse position,
transformed to LonLat coordinates. Then all the visible layers are
queried for features intersecting the "mouse position geometry".

There are some issues/questions though:

* Selecting Point-like features
Using the intersection test, features whose geometry is Point have a
very small "selection area" although they may be a lot bigger on the
screen, shown as a externalGraphic image or something else. So
selecting them doesn't work like it's supposed to. I tried to get
around this problem by using the style properties of the feature
(graphicWidth etc.) to construct a "view geometry" to be used in the
intersection tests.

* Different coordinates in event
For some reason, the event.xy Pixel seems to be a bit (9 pixels) off.
The (layerX,layerY) seemed to right...

* Not messing with map navigation
When navigating the map by holding down the mouse button, the features
shouldn't get selected. In original implementation (that got the
features id straight from the event) this was not a problem since no
events with features id in it were generated during navigation (?).
Using the coordinates however, during/at the end of navigation the
browser sends events whose coordinates may be on top of a feature. I
got around this by ignoring all the events between "mousedown" event
and a "click" event if the "mousedown" didn't happen on top of any
feature.


If nobody is working on this issue, I could develop this further and
maybe even get something ready for the trunk if somebody can convince
me that this is the right (or only) way to do it. I'd appreciate if
somebody has any suggestions or a better idea how to do this. All this
geometry selection thing seems a bit too much for this kind of issue.
I think somebody suggested something like moving all the layer
rendering to a single SVG element (I don't have any idea how to do
that). At least that would get rid of this geometry intersection mess.
With geometries however, it would be possible to implement something
like area selection tools etc...

- antti
_______________________________________________
Dev mailing list
Dev@...
http://openlayers.org/mailman/listinfo/dev

Re: Selecting features on multiple layers

by pi_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antti,

I tried your patch posted for Ticket #434 using your demo at http://sama.asia/ola/mulafese-demo.html

It worked fine in FF3, however did not work in IE 6.

Do you have any plans to get this working in IE? This would be a great help to our project since this is a important fix/feature that we've needed for a long time now.

thx
pi


Antti Nieminen wrote:
Hello,

I've worked a bit with the feature event issue for multiple layers,
described in ticket #434.
http://trac.openlayers.org/ticket/434

I did pretty much what crschmidt suggested in the ticket. ...

...If nobody is working on this issue, I could develop this further and
maybe even get something ready for the trunk if somebody can convince
me that this is the right (or only) way to do it. I'd appreciate if
somebody has any suggestions or a better idea how to do this.

- antti
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev

Re: Selecting features on multiple layers

by robelix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antti Nieminen wrote:
Hello,

I've worked a bit with the feature event issue for multiple layers,
described in ticket #434.
http://trac.openlayers.org/ticket/434
A small change, to make it work in IE7, too

In MultiLayerFeature.js  at line 344:

    createEventGeometry: function(evt) {
      var x = evt.layerX;
      var y = evt.layerY;

change to:
        var x = evt.xy.x;
        var y = evt.xy.y;

It seems that the coordinates sometimes differ a few pixel in FF, but the .layerX/Y are undefined in IE. Maybe add a check if layerX/Y is defined?
LightInTheBox - Buy quality products at wholesale price