Changeset 1702
- Timestamp:
- 10/17/06 18:23:19 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer.js
r1695 r1702 446 446 }, 447 447 448 /** Calculates based on resolution, center, and mapsize 449 * 450 * @param {float} resolution Specific resolution to get an extent for. 451 * If null, this.getResolution() is called 448 /** 452 449 * @returns A Bounds object which represents the lon/lat bounds of the 453 450 * current viewPort. 454 451 * @type OpenLayers.Bounds 455 452 */ 456 getExtent: function(resolution) { 457 var extent = null; 458 459 var center = this.map.getCenter(); 460 if (center != null) { 461 462 if (resolution == null) { 463 resolution = this.getResolution(); 464 } 465 var size = this.map.getSize(); 466 var w_deg = size.w * resolution; 467 var h_deg = size.h * resolution; 468 469 extent = new OpenLayers.Bounds(center.lon - w_deg / 2, 470 center.lat - h_deg / 2, 471 center.lon + w_deg / 2, 472 center.lat + h_deg / 2); 473 474 } 475 476 return extent; 453 getExtent: function() { 454 // just use stock map calculateBounds function -- passing no arguments 455 // means it will user map's current center & resolution 456 // 457 return this.map.calculateBounds(); 477 458 }, 478 459 trunk/openlayers/lib/OpenLayers/Map.js
r1695 r1702 607 607 return size; 608 608 }, 609 610 /** 611 * @param {OpenLayers.LonLat} center Default is this.getCenter() 612 * @param {float} resolution Default is this.getResolution() 613 * 614 * @returns A Bounds based on resolution, center, and current mapsize. 615 * @type OpenLayers.Bounds 616 */ 617 calculateBounds: function(center, resolution) { 618 619 var extent = null; 620 621 if (center == null) { 622 center = this.getCenter(); 623 } 624 if (resolution == null) { 625 resolution = this.getResolution(); 626 } 627 628 if ((center != null) && (resolution != null)) { 629 630 var size = this.getSize(); 631 var w_deg = size.w * resolution; 632 var h_deg = size.h * resolution; 633 634 extent = new OpenLayers.Bounds(center.lon - w_deg / 2, 635 center.lat - h_deg / 2, 636 center.lon + w_deg / 2, 637 center.lat + h_deg / 2); 638 639 } 640 641 return extent; 642 }, 643 609 644 610 645 /********************************************************/
