2

I've set up a WFS layer in OpenLayers:

 var v1497_shp = new OpenLayers.Layer.Vector("v1497_shp", {
     strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
     protocol: new OpenLayers.Protocol.WFS({
         version: "1.1.0",
         // loading data through localhost url path
         url: "http://localhost/geoserver/wfs",
         featureNS :  "http://www.opengeospatial.net/cite",
         maxExtent: mapextent,
         // layer name
         featureType: "v1497_db_wfs",
         // geometry column name
         geometryName: "the_geom",
         schema: "http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:v1497_db_wfs"
     })
});

Now I want to highlight the layer when I pass over with the mouse.

Can I do this?

3

only using highlight features on hover:

(this examples also show how eventListeners are used with beforefeaturehighlighted, featurehighlighted, featureunhighlighted)

 var info = function(evt) {
                OpenLayers.Console.log(evt.type, evt.feature.id);
            };

 var highlight = new OpenLayers.Control.SelectFeature(v1497_shp, {
                hover: true,
                highlightOnly: true,
                renderIntent: "temporary",
                eventListeners: {
                    beforefeaturehighlighted: info ,
                    featurehighlighted: info ,
                    featureunhighlighted: info 
                }
            });

map.addControl(highlight);
highlight.activate();

working examples here...

i hope it helps you...

0
1

Use a SelectFeature control with hover and higlightOnly

var select = new OpenLayers.Control.SelectFeature(v1497_shp, { highlightOnly: true, hover: true });
map.addControl(select);
select.activate();
select.events.register("featurehighlighted",this,function(e){console.log("hover ",e);});
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.