Hi,
I have a simple task; I'm trying to highlight a vector feature when the mouse
hovers over it.
I've followed as best I can the example, "SelectFeature Control on
Layer.Vector", but a hover does not change the feature's line colour in my app.
The relevant code is below, I'm using the latest version of OpenLayers (2.7),
can anyone see where I've gone wrong.
Any help appreciated,
Dave
function addSurvey()
{
//Add survey vector layer
var surveyLayer = new OpenLayers.Layer.Vector("Survey");
//Construct a linear feature for each survey line
var features = [];
for(var i in data.features)
{
var point = [];
var coords = data.features[i].geometry.coordinates;
for(var j in coords)
{
point.push(new OpenLayers.Geometry.Point(coords[j][0], coords[j][1]));
}
features.push(new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.LineString(point), null, {strokeColor: "#00ffff",
strokeWidth: 2, hoverStrokeColor: "#ff0000", hoverStrokeWidth: 2}));
}
//Add features to layer and layer to map
map.addLayer(surveyLayer);
surveyLayer.addFeatures(features);
//Add a hover feature select control
ctrlHover = new OpenLayers.Control.SelectFeature(surveyLayer,
{
multiple: false,
hover: true,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey" // shift key adds to selection
});
map.addControl(ctrlHover);
ctrlHover.activate();
}
--
View this message in context:
http://n2.nabble.com/SelectFeature-Control-tp2562414p2562414.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users