[OpenLayers-Commits] r11721 - trunk/openlayers/lib/OpenLayers/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Mar 22 09:46:03 EDT 2011


Author: ahocevar
Date: 2011-03-22 06:45:58 -0700 (Tue, 22 Mar 2011)
New Revision: 11721

Modified:
   trunk/openlayers/lib/OpenLayers/Layer/PointTrack.js
Log:
Making Layer.PointTrack play nicely with gx:Track from Format.KML. Thanks bartvde for the updated patch. r=fredj,bartvde (closes #2792)


Modified: trunk/openlayers/lib/OpenLayers/Layer/PointTrack.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/PointTrack.js	2011-03-22 12:30:41 UTC (rev 11720)
+++ trunk/openlayers/lib/OpenLayers/Layer/PointTrack.js	2011-03-22 13:45:58 UTC (rev 11721)
@@ -20,13 +20,23 @@
   
     /**
      * APIProperty:
-     * dataFrom  - {<OpenLayers.Layer.PointTrack.dataFrom>} optional. If the
-     *             lines should get the data/attributes from one of the two
-     *             points, creating it, which one should it be?
+     * dataFrom  - {<OpenLayers.Layer.PointTrack.TARGET_NODE>} or
+     *     {<OpenLayers.Layer.PointTrack.SOURCE_NODE>} 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  - {<OpenLayers.Layer.PointTrack.TARGET_NODE>} or
+     *     {<OpenLayers.Layer.PointTrack.SOURCE_NODE>} 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 @@
      * 
      * Parameters:
      * pointFeatures - {Array(<OpenLayers.Feature>)}
+     * 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 @@
                         (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 <OpenLayers.Layer.PointTrack.dataFrom> and
+ * <OpenLayers.Layer.PointTrack.styleFrom>
+ */
+OpenLayers.Layer.PointTrack.SOURCE_NODE = -1;
+
+/**
+ * Constant: OpenLayers.Layer.PointTrack.TARGET_NODE
+ * {Number} value for <OpenLayers.Layer.PointTrack.dataFrom> and
+ * <OpenLayers.Layer.PointTrack.styleFrom>
+ */
+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};
-



More information about the Commits mailing list