Open layers and events in multiple layers (openlayer. Layer. Vector)
Another day working with openlayers and another problem
That is, for different types of things (cars, history and regional travel), I have multiple vector layers They all have events, I try to catch... But as Niklas found out, when you activate an event on a layer, it is moved to the top, and events above the layer will not be fired
Is there any way around this? Because when I move the area polygon, I want the event to trigger and display its name. When I move the mouse to the car tag, I also want the event fire No, I don't want to put them on the same layer, because I want to turn them off or quickly without looping through all the functions and disabling them
Allen
Edit1: I did some searches and found that you can use the same control on multiple layers This may solve the problem for me I check it ATM and test whether adding more layers to a single control is to solve my problem or not
> Forcing an OpenLayers Markers layer to draw on top,and having selectable layers beneath
Solution
When I encountered the same problem, I found this problem and tried to make multiple layers respond to mouse events
Solution, just in case someone finds this thread is much simpler
The selectfeature control takes a vector layer array. If all buffers you need to respond to mouse events (hover and click) are in this array, they can work, not just the buffer moved to the top
Therefore, in the approved solution of this thread, this can greatly simplify:
this.carSelect = new OpenLayers.Control.SelectFeature( [this.vectorsLayer,this.carsLayer],{ 'hover':true,'callbacks': { blah blah blah } });
This will register the appropriate events on both layers and make them effective at the same time
I hope this will help anyone stumble over the problem
As mentioned elsewhere, it is not difficult to use openlayers and find the right way to do things