Changeset 7678
- Timestamp:
- 08/01/08 21:56:36 (4 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/BaseTypes/Bounds.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (2 diffs)
- trunk/openlayers/tests/BaseTypes/Bounds.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/BaseTypes/Bounds.js
r6833 r7678 218 218 return new OpenLayers.LonLat( (this.left + this.right) / 2, 219 219 (this.bottom + this.top) / 2); 220 }, 221 222 /** 223 * Method: scale 224 * Scales the bounds around a pixel or lonlat. Note that the new 225 * bounds may return non-integer properties, even if a pixel 226 * is passed. 227 * 228 * Parameters: 229 * ratio - {Float} 230 * origin - {<OpenLayers.Pixel> or <OpenLayers.LonLat>} 231 * Default is center. 232 * 233 * Returns: 234 * {<OpenLayers.Bound>} A new bounds that is scaled by ratio 235 * from origin. 236 */ 237 238 scale: function(ratio, origin){ 239 if(origin == null){ 240 origin = this.getCenterLonLat(); 241 } 242 243 var bounds = []; 244 245 var origx,origy; 246 247 // get origin coordinates 248 if(origin.CLASS_NAME == "OpenLayers.LonLat"){ 249 origx = origin.lon; 250 origy = origin.lat; 251 } else { 252 origx = origin.x; 253 origy = origin.y; 254 } 255 256 var left = (this.left - origx) * ratio + origx; 257 var bottom = (this.bottom - origy) * ratio + origy; 258 var right = (this.right - origx) * ratio + origx; 259 var top = (this.top - origy) * ratio + origy; 260 261 return new OpenLayers.Bounds(left, bottom, right, top); 220 262 }, 221 263 trunk/openlayers/lib/OpenLayers/Map.js
r7627 r7678 198 198 199 199 /** 200 * Property: panRatio 201 * {Float} The ratio of the current extent within 202 * which panning will tween. 203 */ 204 panRatio: 1.5, 205 206 /** 200 207 * Property: viewRequestID 201 208 * {String} Used to store a unique identifier that changes when the map … … 1369 1376 */ 1370 1377 panTo: function(lonlat) { 1371 if (this.panMethod && this.getExtent(). containsLonLat(lonlat)) {1378 if (this.panMethod && this.getExtent().scale(this.panRatio).containsLonLat(lonlat)) { 1372 1379 if (!this.panTween) { 1373 1380 this.panTween = new OpenLayers.Tween(this.panMethod); trunk/openlayers/tests/BaseTypes/Bounds.html
r6724 r7678 558 558 } 559 559 560 function test_Bounds_scale(t) { 561 t.plan(3); 562 563 origBounds = new OpenLayers.Bounds(1,2,3,4); 564 bounds = origBounds.scale(2); 565 var b = new OpenLayers.Bounds(0,1,4,5); 566 t.ok(bounds.equals(b), "Bounds scale correctly with default origin at center") 567 568 var origin = new OpenLayers.Pixel(0,1); 569 bounds = origBounds.scale(2,origin); 570 b = new OpenLayers.Bounds(2,3,6,7); 571 t.ok(bounds.equals(b), "Bounds scale correctly with offset origin"); 572 573 origin = new OpenLayers.Pixel(5,1); 574 bounds = bounds.scale(2, origin); 575 b = new OpenLayers.Bounds(-1, 5, 7, 13); 576 t.ok(bounds.equals(b), "Bounds scale correctly with offset origin"); 577 578 } 560 579 561 580 </script>
