I am rendering a vector linestring via GeoJSON on top of an OpenLayers map. I'd like to alternate the styling between two slightly different shades of blue, such that the colors alternate from one line segment to the next. Is there any way to do this, apart from using points instead of a linestring and constructing the line segments myself?
var path;
function drawPath(table, x, y, id) {
var urlreq = "../grab.php?method=get_path&x=" + x + "&y=" + y + "&table=" + table +
"&id=" + id;
if( typeof(path) != 'undefined' ) { map.removeLayer(path); }
path = new OpenLayers.Layer.Vector("Path", {
projection: epsg900913,
style: {
strokeColor: "blue",
strokeWidth: 3
},
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: urlreq,
format: new OpenLayers.Format.GeoJSON()
})
});
map.addLayer(path);
}