Currently I am trying to change the icon of a particular feature of a vector layer that the user is focusing on. I add each feature to the map like so:
var point = new OpenLayers.Geometry.Point(pt.lon, pt.lat);
var markerStyle = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {
externalGraphic: iconURL
});
var marker = new OpenLayers.Feature.Vector(point, attributes, markerStyle);
Later I do the following to update the feature's icon:
var marker = this.findSelectedMarker();
if (marker) {
marker.style.externalGraphic = newIconUrl;
this.layer.redraw();
}
But when the layer redraws, all features in my layer use the newIconUrl
, not simply the selected marker that I am trying to update.
How can I change the icon of the one selected feature of my layer? Thanks.