diff --git a/lib/OpenLayers/Layer/PointTrack.js b/lib/OpenLayers/Layer/PointTrack.js index fdacaaf5ce..e8d5e7d7b7 100644 --- a/lib/OpenLayers/Layer/PointTrack.js +++ b/lib/OpenLayers/Layer/PointTrack.js @@ -20,12 +20,22 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, { /** * APIProperty: - * dataFrom - {} optional. If the - * lines should get the data/attributes from one of the two - * points, creating it, which one should it be? + * dataFrom - {} or + * {} optional. If the lines + * should get the data/attributes from one of the two points it is + * composed of, which one should it be? */ dataFrom: null, + /** + * APIProperty: + * styleFrom - {} or + * {} optional. If the lines + * should get the style from one of the two points it is composed of, + * which one should it be? + */ + styleFrom: null, + /** * Constructor: OpenLayers.PointTrack * Constructor for a new OpenLayers.PointTrack instance. @@ -47,9 +57,12 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, { * * Parameters: * pointFeatures - {Array()} + * options - {Object} * + * Supported options: + * silent - {Boolean} true to suppress (before)feature(s)added events */ - addNodes: function(pointFeatures) { + addNodes: function(pointFeatures, options) { if (pointFeatures.length < 2) { OpenLayers.Console.error( "At least two point features have to be added to create" + @@ -78,26 +91,43 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, { (pointFeatures[i+this.dataFrom].data || pointFeatures[i+this.dataFrom].attributes) : null; + var style = (this.styleFrom != null) ? + (pointFeatures[i+this.styleFrom].style) : + null; var line = new OpenLayers.Geometry.LineString([startPoint, endPoint]); - lines[i-1] = new OpenLayers.Feature.Vector(line, attributes); + lines[i-1] = new OpenLayers.Feature.Vector(line, attributes, + style); } startPoint = endPoint; } - this.addFeatures(lines); + this.addFeatures(lines, options); }, CLASS_NAME: "OpenLayers.Layer.PointTrack" }); +/** + * Constant: OpenLayers.Layer.PointTrack.SOURCE_NODE + * {Number} value for and + * + */ +OpenLayers.Layer.PointTrack.SOURCE_NODE = -1; + +/** + * Constant: OpenLayers.Layer.PointTrack.TARGET_NODE + * {Number} value for and + * + */ +OpenLayers.Layer.PointTrack.TARGET_NODE = 0; + /** * Constant: OpenLayers.Layer.PointTrack.dataFrom - * {Object} with the following keys + * {Object} with the following keys - *deprecated* * - SOURCE_NODE: take data/attributes from the source node of the line * - TARGET_NODE: take data/attributes from the target node of the line */ OpenLayers.Layer.PointTrack.dataFrom = {'SOURCE_NODE': -1, 'TARGET_NODE': 0}; -