Oh, I overlooked the side-menu issue. Okay, no problem.
Give each feature an ID and store it in an array. When you mouse over
the side menu item, that also knows the id, do a select of the feature.
Here is the code of my page that does that:
function genOver(e){
resetLines();
this.style.backgroundColor = "#aaaaaa";
var line = boats[this.ix].line;
if (line == null) return;// has not been made yet
select.select(line);
}
The "this" referred to above is the <li> that contains the label. I
gave it an "ix" attribute that got me to the feature (line)
I invoke this feature when creating the div by adding
".onmouseover=genOver;" to it.
I'd like to take credit for this setup, but I stole it.
You can see the whole shebang in operation on my test site, which I will
leave up for at least a week:
http://pacificcup.org/OpenLayers/pcycopen5.php
Sorry for the sloppy other code in it, this is my first OL project.
Michael
On 10/11/2010 11:06 AM, William Martin wrote:
All,
I've got some vector features, and I'd like to change their opacity when the
user mouses over a link in a side-menu. The map always has a set number of
features (17 county outlines) with predictable feature indices, so I can get
appropriate vector feature easily enough:
vector = new OpenLayers.Layer.Vector("Vector Layer", {style:
OpenLayers.Feature.Vector.style['default']});
for(i = 1; i< counties.length; i++){
cur = counties[i];
var details = {name: cur.name, url: cur.url}
// Prep some attribues.
attributes = {name: cur.name};
style = cur.style; // The initial styles are set in the counties array.
// Draw the boundaries of the county.
vertices = new OpenLayers.Geometry.LinearRing(cur.bounds);
counties[i] = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Polygon(vertices), details, style);
vector.addFeatures(counties[i]);
}
... and then I can get the county with vector.features[0] (or 1, 2, 3, etc).
So now that I've got that, how do I set the opacity of the selected feature?
I've tried this:
vector.features[0].style.fillOpacity = 0.5;
But it has no effect. I tried this to get a readout of all the properties and
methods of the feature:
for(i in vector.features[0]){ console.log(i); }
But it doesn't show a setOpacity method or anything. What am I missing, please?
Thanks.
Will Martin
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users