OpenLayers – Custom Feature Style

Topic: OpenLayers – Custom Feature Style
Descriptions: To enable custom style to a particular feature by using renderIntent & adding new styleMap.
- Get Feature;
var o = target_layer.features[3];
- Set Style Name;
var styleName = o.id + '_style';
- Set render intent;
o.renderIntent = styleName;
- Set the custom style;
var style = new OpenLayers.Style({externalGraphic:'icons/marker_1.png'});
- Add new style to styleMap;
o.layer.styleMap.styles[styleName] = style;
- Assign back to the layer’s feature;
target_layer.features[3] = o;
- Call redraw method in
o.layer;
o.layer.redraw();