I did some testing with your code. First thing I did was attach a click event to the vector layer and it seems like the reason that the vector layer always takes priority is the vector layer will trigger a click event if you click anywhere on the map, not just the feature. I can only assume this is due to the way that firefox handles SVGs, so long story short, there may be nothing you can do about this.
However, having the markers on top of the vector layer seems to accomplish your task just fine...why does the vector layer need to be on top of the markers layer? -Adam On Wed, Sep 22, 2010 at 2:01 PM, katiea <katie.ad...@spidasoftware.com>wrote: > > Hey, I'm still searching for some help on this issue, if anyone has any > ideas. > > Thank you! > > > > katiea wrote: > > > > Hi, > > > > I'm in the process of moving our Google Maps application to OpenLayers > and > > have run into a problem. Very basically, what I need are two layers. > One > > layer needs selectable dots (can be markers or features). The other > layer > > needs draggable features. I need to be able to use both layers without > > having to switch between them. > > > > The problem is that in FireFox (I'm running 3.6.9), mouse events do not > > seem to fall through the vector layers to the layers beneath. So, if I > > have a marker layer with a higher z-index than a vector layer, I can > click > > a marker and select a feature, but if the vector layer z-index is higher, > > I can select the feature but not click the marker. > > > > I have tried this in IE8 and Chrome and they both work as I would expect, > > with both layers getting the mouse events. I'd like to know if this is a > > bug or if I'm doing something wrong. I need this for an essential part > of > > our application, so I'm open to suggestions about how this could be > > achieved. > > > > The code below is a simple function that demonstrates the issue. The > > "switch" button reverses the z-indexes of the layers. The behavior > > happens with a markers layer and a vector layer, or with two vector > > layers. You can test both by switching the commented section in the > code. > > > > I would seriously appreciate any help. Thanks! > > > > Katie > > > > > > > > var markers; > > var vector; > > function Test(){ > > var startLocation = new OpenLayers.LonLat(-80.07,36.08); > > var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", > > "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: > > 'basic'} ); > > > > var mapObject = new OpenLayers.Map('map'); > > mapObject.addControl(new > > OpenLayers.Control.LayerSwitcher({'ascending':false})); > > mapObject.addLayer(layer); > > > > mapObject.setCenter(startLocation); > > > > vector = new OpenLayers.Layer.Vector("Vector"); > > > > > > mapObject.addLayer(vector); > > var selectFeat = new OpenLayers.Control.SelectFeature(vector, > {toggle: > > true, clickout:false}); > > selectFeat.handlers['feature'].stopDown = false; > > selectFeat.handlers['feature'].stopUp = false; > > mapObject.addControl(selectFeat); > > selectFeat.activate(); > > > > ////// > > //markers = new OpenLayers.Layer.Vector("Markers"); > > markers = new OpenLayers.Layer.Markers("Markers"); > > mapObject.addLayer(markers); > > // var selectFeat2 = new OpenLayers.Control.SelectFeature(markers, > > {toggle: true, clickout:false}); > > // selectFeat2.handlers['feature'].stopDown = false; > > // selectFeat2.handlers['feature'].stopUp = false; > > // mapObject.addControl(selectFeat2); > > // selectFeat2.activate(); > > > > var marker = new OpenLayers.Marker(startLocation, new > > OpenLayers.Icon(" > http://localhost:8888/projectmanager/images/default_model_images/orange-ring.png > ", > > new OpenLayers.Size(25,25))); > > markers.addMarker(marker); > > marker.events.register('click', this, function(latlng) { > > alert("Marker clicked at " + latlng); > > }, 400); > > > > // var marker = new OpenLayers.Geometry.Point(startLocation.lon, > > startLocation.lat); > > // var feature2 = new OpenLayers.Feature.Vector(marker); > > // markers.addFeatures(new Array(feature2)); > > //////// > > > > markers.events.fallThrough = true; > > vector.events.fallThrough = true; > > > > > > markers.setZIndex(2344); > > vector.setZIndex(2345); > > var pointsArray = []; > > pointsArray[0] = new OpenLayers.Geometry.Point(-82.07, 39.08); > > pointsArray[1] = new OpenLayers.Geometry.Point(-82.07, 41.08); > > pointsArray[2] = new OpenLayers.Geometry.Point(-84.07, 41.08); > > pointsArray[3] = new OpenLayers.Geometry.Point(-84.07, 39.08); > > var linearRing = new OpenLayers.Geometry.LinearRing(pointsArray); > > var feature = new OpenLayers.Feature.Vector(linearRing); > > vector.addFeatures(new Array(feature)); > > > > var button = document.createElement('input'); > > button.setAttribute('type', 'button'); > > button.setAttribute('value', "Switch"); > > button.setAttribute('onClick', "switchZ()"); > > document.getElementById('forms').appendChild(button); > > } > > function switchZ(){ > > if(parseInt(markers.getZIndex()) > parseInt(vector.getZIndex())){ > > markers.setZIndex(2344); > > vector.setZIndex(2345); > > } > > else{ > > vector.setZIndex(2344); > > markers.setZIndex(2345); > > } > > alert("Markers ZIndex: " + markers.getZIndex() + " Vector ZIndex: " + > > vector.getZIndex()); > > } > > > > > > -- > View this message in context: > http://osgeo-org.1803224.n2.nabble.com/Multiple-Vector-Layers-mouse-events-in-FireFox-tp5538363p5560093.html > Sent from the OpenLayers Users mailing list archive at Nabble.com. > _______________________________________________ > Users mailing list > us...@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/openlayers-users >
_______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users