Making Layer.PointTrack play nicely with gx:Track from Format.KML. Thanks bartvde for the updated patch. r=fredj,bartvde (closes #2792)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11721 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -20,12 +20,22 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty:
|
* APIProperty:
|
||||||
* dataFrom - {<OpenLayers.Layer.PointTrack.dataFrom>} optional. If the
|
* dataFrom - {<OpenLayers.Layer.PointTrack.TARGET_NODE>} or
|
||||||
* lines should get the data/attributes from one of the two
|
* {<OpenLayers.Layer.PointTrack.SOURCE_NODE>} optional. If the lines
|
||||||
* points, creating it, which one should it be?
|
* should get the data/attributes from one of the two points it is
|
||||||
|
* composed of, which one should it be?
|
||||||
*/
|
*/
|
||||||
dataFrom: null,
|
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: OpenLayers.PointTrack
|
||||||
* Constructor for a new OpenLayers.PointTrack instance.
|
* Constructor for a new OpenLayers.PointTrack instance.
|
||||||
@@ -47,9 +57,12 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* pointFeatures - {Array(<OpenLayers.Feature>)}
|
* 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) {
|
if (pointFeatures.length < 2) {
|
||||||
OpenLayers.Console.error(
|
OpenLayers.Console.error(
|
||||||
"At least two point features have to be added to create" +
|
"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].data ||
|
||||||
pointFeatures[i+this.dataFrom].attributes) :
|
pointFeatures[i+this.dataFrom].attributes) :
|
||||||
null;
|
null;
|
||||||
|
var style = (this.styleFrom != null) ?
|
||||||
|
(pointFeatures[i+this.styleFrom].style) :
|
||||||
|
null;
|
||||||
var line = new OpenLayers.Geometry.LineString([startPoint,
|
var line = new OpenLayers.Geometry.LineString([startPoint,
|
||||||
endPoint]);
|
endPoint]);
|
||||||
|
|
||||||
lines[i-1] = new OpenLayers.Feature.Vector(line, attributes);
|
lines[i-1] = new OpenLayers.Feature.Vector(line, attributes,
|
||||||
|
style);
|
||||||
}
|
}
|
||||||
|
|
||||||
startPoint = endPoint;
|
startPoint = endPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addFeatures(lines);
|
this.addFeatures(lines, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Layer.PointTrack"
|
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
|
* 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
|
* - SOURCE_NODE: take data/attributes from the source node of the line
|
||||||
* - TARGET_NODE: take data/attributes from the target 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};
|
OpenLayers.Layer.PointTrack.dataFrom = {'SOURCE_NODE': -1, 'TARGET_NODE': 0};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user