Changeset 6947
- Timestamp:
- 04/15/08 21:56:21 (5 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Vector.js (modified) (1 diff)
- trunk/openlayers/tests/Layer/Vector.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Vector.js
r6901 r6947 535 535 }, 536 536 537 /** 538 * APIMethod: getDataExtent 539 * Calculates the max extent which includes all of the features. 540 * 541 * Returns: 542 * {<OpenLayers.Bounds>} 543 */ 544 getDataExtent: function () { 545 var maxExtent = null; 546 if( this.features && (this.features.length > 0)){ 547 var maxExtent = this.features[0].geometry.getBounds(); 548 for(var i=0; i < this.features.length; i++){ 549 maxExtent.extend(this.features[i].geometry.getBounds()); 550 } 551 } 552 553 return maxExtent; 554 }, 555 537 556 CLASS_NAME: "OpenLayers.Layer.Vector" 538 557 }); trunk/openlayers/tests/Layer/Vector.html
r6724 r6947 17 17 18 18 function test_Layer_Vector_addFeatures(t) { 19 t.plan( 4);19 t.plan(5); 20 20 21 21 var layer = new OpenLayers.Layer.Vector(name); … … 44 44 45 45 layer.addFeatures([pointFeature], {silent: true}); 46 47 var extent = layer.getDataExtent(); 48 t.eq(extent.toBBOX(), "-111.04,45.68,-111.04,45.68", "extent from getDataExtent is correct"); 46 49 } 47 50
