#832 - changing the name of the second arg for the Feature.Vector constructor, mainly for documentation sake - note that this is not an api change - Feature.Vector inherits from Feature - Feature exposes a data property, Feature.Vector exposes an attributes property, both point to the same thing for Feature.Vector - this change does not alter that redundancy, only changes the argument names for the constructor - and adds tests - I'll leave the data/attributes property discussion for later
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3717 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -66,17 +66,20 @@ OpenLayers.Feature.Vector.prototype =
|
||||
* Parameters:
|
||||
* geometry - {<OpenLayers.Geometry>} The geometry that this feature
|
||||
* represents.
|
||||
* data - {Object} An optional object that will be mapped to <attributes>.
|
||||
* attributes - {Object} An optional object that will be mapped to the
|
||||
* <attributes> property.
|
||||
* style - {Object} An optional style object.
|
||||
*/
|
||||
initialize: function(geometry, data, style) {
|
||||
OpenLayers.Feature.prototype.initialize.apply(this, [null, null, data]);
|
||||
initialize: function(geometry, attributes, style) {
|
||||
OpenLayers.Feature.prototype.initialize.apply(this,
|
||||
[null, null, attributes]);
|
||||
this.lonlat = null;
|
||||
this.geometry = geometry;
|
||||
this.state = null;
|
||||
this.attributes = new Object();
|
||||
if (data) {
|
||||
this.attributes = OpenLayers.Util.extend(this.attributes, data);
|
||||
if (attributes) {
|
||||
this.attributes = OpenLayers.Util.extend(this.attributes,
|
||||
attributes);
|
||||
}
|
||||
this.style = style ? style : null;
|
||||
},
|
||||
|
||||
@@ -5,12 +5,22 @@
|
||||
var map;
|
||||
var feature;
|
||||
|
||||
function test_01_Feature_Vector_constructor (t) {
|
||||
t.plan( 1 );
|
||||
function test_Feature_Vector_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var geometry = new OpenLayers.Geometry();
|
||||
geometry.id = Math.random();
|
||||
var style = {foo: "bar"};
|
||||
var attributes = {bar: "foo"};
|
||||
|
||||
feature = new OpenLayers.Feature.Vector();
|
||||
feature = new OpenLayers.Feature.Vector(geometry, attributes, style);
|
||||
|
||||
t.ok( feature instanceof OpenLayers.Feature.Vector, "new OpenLayers.Feature.Vector returns Feature.Vector object" );
|
||||
t.ok(feature instanceof OpenLayers.Feature.Vector,
|
||||
"new OpenLayers.Feature.Vector returns Feature.Vector object" );
|
||||
t.eq(feature.attributes, attributes,
|
||||
"attributes property set properly" );
|
||||
t.eq(feature.geometry.id, geometry.id,
|
||||
"geometry.property set properly" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user