Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've set up a WFS layer in openlayer:

 var v1497_shp = new OpenLayers.Layer.Vector("v1497_shp", {
     strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
     //projection: new OpenLayers.Projection("EPSG:26910"),
     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. how can i do this?

Ay idea? Thank you.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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...

share|improve this answer
    
it works! thank you! –  Michele 2 May 9 '12 at 12:57
add comment

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);});
share|improve this answer
    
it works! thank you! –  Michele 2 May 9 '12 at 12:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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