I am trying to draw separate line segments on a single layer in using Openlayers. The site can be seen Here (click the map then zoom in). The red boxes represent a quad-tree containing road segments. And the green line shows up as a single polyline, and I would like it to be viewed as individual segments.
Here is my existing function
function DrawSegments(response){
var SegmentsData = eval( '(' + response.responseText + ')' );
var line;
var lineFeature;
if(segmentsLayer)
segmentsLayer.destroy();
segmentsLayer = new OpenLayers.Layer.Vector("Segments");
var points = new Array();
var style = { strokeColor: '#00ff00',
strokeOpacity: 0.8,
strokeWidth: 2
};
map.addLayer(segmentsLayer);
map.addControl(new OpenLayers.Control.DrawFeature(segmentsLayer, OpenLayers.Handler.Path));
//Used this block as code example to possibly add lines using a WKT geometry collection
//var feature = new OpenLayers.Feature.Vector(
//OpenLayers.Geometry.fromWKT(
//"POLYGON((28.828125 0.3515625, 132.1875 -13.0078125, -1.40625 -59.4140625, 28.828125 0.3515625))"
//).transform(WGS,SMP)
//);
//segmentsLayer.addFeatures([feature]);
for (var i = 0; i < SegmentsData.length; i++) {
points.push(new OpenLayers.Geometry.Point(SegmentsData[i][0], SegmentsData[i][1]).transform(WGS,SMP));
points.push(new OpenLayers.Geometry.Point(SegmentsData[i][2], SegmentsData[i][3]).transform(WGS,SMP));
line = new OpenLayers.Geometry.LineString(points);
lineFeature = new OpenLayers.Feature.Vector(line, null, style);
}
segmentsLayer.addFeatures([lineFeature]);
}
I've tried:
Finding examples for
OpenLayers.Geometry.MultiLineStringand
OpenLayers.Geometry.Collection
I've tried turning the lineFeature var into an array and adding each array element separately with no luck. Documentations not helping me. Any help would be greatly appreciated.