Changeset 6310
- Timestamp:
- 02/15/08 15:09:51 (1 year ago)
- Files:
-
- sandbox/achipa/openlayers/common.js (added)
- sandbox/achipa/openlayers/examples/timeLevels.html (added)
- sandbox/achipa/openlayers/img/time-minus-mini.png (added)
- sandbox/achipa/openlayers/img/time-plus-mini.png (added)
- sandbox/achipa/openlayers/img/time-world-mini.png (added)
- sandbox/achipa/openlayers/img/timebar.png (added)
- sandbox/achipa/openlayers/lib/OpenLayers.js (modified) (8 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/DateTime.js (modified) (3 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTime.js (added)
- sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTimeBar.js (added)
- sandbox/achipa/openlayers/lib/OpenLayers/Control/TimeZoom.js (added)
- sandbox/achipa/openlayers/lib/OpenLayers/Layer.js (modified) (67 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/achipa/openlayers/lib/OpenLayers.js
r6180 r6310 3 3 * full text of the license. */ 4 4 5 /* 5 /* 6 6 * @requires OpenLayers/BaseTypes.js 7 */ 7 */ 8 8 9 9 (function() { … … 15 15 */ 16 16 var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile); 17 17 18 18 /** 19 19 * Namespace: OpenLayers … … 21 21 */ 22 22 window.OpenLayers = { 23 23 24 24 /** 25 25 * Property: _scriptName … … 38 38 var scriptLocation = ""; 39 39 var scriptName = OpenLayers._scriptName; 40 40 41 41 var scripts = document.getElementsByTagName('script'); 42 42 for (var i = 0; i < scripts.length; i++) { 43 43 var src = scripts[i].getAttribute('src'); 44 44 if (src) { 45 var index = src.lastIndexOf(scriptName); 45 var index = src.lastIndexOf(scriptName); 46 46 // set path length for src up to a query string 47 47 var pathLength = src.lastIndexOf('?'); … … 62 62 * OpenLayers.singleFile is a flag indicating this file is being included 63 63 * in a Single File Library build of the OpenLayers Library. 64 * 64 * 65 65 * When we are *not* part of a SFL build we dynamically include the 66 66 * OpenLayers library code. 67 * 68 * When we *are* part of a SFL build we do not dynamically include the 67 * 68 * When we *are* part of a SFL build we do not dynamically include the 69 69 * OpenLayers library code as it will be appended at the end of this file. 70 70 */ … … 147 147 "OpenLayers/Control/PanZoom.js", 148 148 "OpenLayers/Control/PanZoomBar.js", 149 "OpenLayers/Control/PanTime.js", 150 "OpenLayers/Control/PanTimeBar.js", 149 151 "OpenLayers/Control/ArgParser.js", 150 152 "OpenLayers/Control/Permalink.js", … … 163 165 "OpenLayers/Geometry/Curve.js", 164 166 "OpenLayers/Geometry/LineString.js", 165 "OpenLayers/Geometry/LinearRing.js", 167 "OpenLayers/Geometry/LinearRing.js", 166 168 "OpenLayers/Geometry/Polygon.js", 167 169 "OpenLayers/Geometry/MultiLineString.js", … … 208 210 var allScriptTags = new Array(jsfiles.length); 209 211 } 210 var host = OpenLayers._getScriptLocation() + "lib/"; 212 var host = OpenLayers._getScriptLocation() + "lib/"; 211 213 for (var i = 0; i < jsfiles.length; i++) { 212 214 if (docWrite) { 213 215 allScriptTags[i] = "<script src='" + host + jsfiles[i] + 214 "'></script>"; 216 "'></script>"; 215 217 } else { 216 218 var s = document.createElement("script"); 217 219 s.src = host + jsfiles[i]; 218 var h = document.getElementsByTagName("head").length ? 219 document.getElementsByTagName("head")[0] : 220 var h = document.getElementsByTagName("head").length ? 221 document.getElementsByTagName("head")[0] : 220 222 document.body; 221 223 h.appendChild(s); sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/DateTime.js
r6269 r6310 3 3 * Instances of this class represent moments or intervals of time. This allows us to 4 4 * give the spatial data a temporal dimension and act accordingly. The default timezone 5 * is UTC and the precision is in seconds. The minimum representable time is 5 * is UTC and the precision is in seconds. The minimum representable time is 6 6 * 1970-01-01T00:00:00Z, and the maximum representable time is 2038-01-19T03:14:07Z 7 * 7 * 8 8 */ 9 9 OpenLayers.DateTime = OpenLayers.Class({ … … 72 72 this.setBegin(targetdate); 73 73 this.setEnd(targetdate); 74 this.interval = false; 74 this.interval = false; 75 75 }, 76 76 … … 138 138 }, 139 139 140 equal: function(dateTime) { 141 if (this.from == dateTime.from && this.to == dateTime.to) return true; 142 return false; 143 }, 144 140 145 CLASS_NAME: "OpenLayers.DateTime" 141 146 sandbox/achipa/openlayers/lib/OpenLayers/Layer.js
r6264 r6310 20 20 id: null, 21 21 22 /** 22 /** 23 23 * APIProperty: name 24 24 * {String} … … 26 26 name: null, 27 27 28 /** 28 /** 29 29 * APIProperty: div 30 30 * {DOMElement} … … 38 38 opacity: null, 39 39 40 /** 40 /** 41 41 * Constant: EVENT_TYPES 42 42 * {Array(String)} Supported application event types 43 43 */ 44 44 EVENT_TYPES: ["loadstart", "loadend", "loadcancel", "visibilitychanged", "datetimechanged"], 45 45 46 46 /** 47 47 * APIProperty: events … … 52 52 /** 53 53 * APIProperty: map 54 * {<OpenLayers.Map>} This variable is set when the layer is added to 54 * {<OpenLayers.Map>} This variable is set when the layer is added to 55 55 * the map, via the accessor function setMap(). 56 56 */ 57 57 map: null, 58 58 59 59 /** 60 60 * APIProperty: isBaseLayer 61 * {Boolean} Whether or not the layer is a base layer. This should be set 61 * {Boolean} Whether or not the layer is a base layer. This should be set 62 62 * individually by all subclasses. Default is false 63 63 */ 64 64 isBaseLayer: false, 65 65 66 66 /** 67 67 * Property: alpha 68 * {Boolean} The layer's images have an alpha channel. Default is false. 68 * {Boolean} The layer's images have an alpha channel. Default is false. 69 69 */ 70 70 alpha: false, 71 71 72 /** 72 /** 73 73 * APIProperty: displayInLayerSwitcher 74 74 * {Boolean} Display the layer's name in the layer switcher. Default is … … 85 85 /** 86 86 * APIProperty: attribution 87 * {String} Attribution string, displayed when an 87 * {String} Attribution string, displayed when an 88 88 * <OpenLayers.Control.Attribution> has been added to the map. 89 89 */ 90 attribution: null, 91 92 /** 90 attribution: null, 91 92 /** 93 93 * Property: inRange 94 * {Boolean} The current map resolution is within the layer's min/max 95 * range. This is set in <OpenLayers.Map.setCenter> whenever the zoom 94 * {Boolean} The current map resolution is within the layer's min/max 95 * range. This is set in <OpenLayers.Map.setCenter> whenever the zoom 96 96 * changes. 97 97 */ 98 98 inRange: false, 99 99 100 100 /** 101 101 * Propery: imageSize 102 * {<OpenLayers.Size>} For layers with a gutter, the image is larger than 102 * {<OpenLayers.Size>} For layers with a gutter, the image is larger than 103 103 * the tile by twice the gutter in each dimension. 104 104 */ 105 105 imageSize: null, 106 106 107 107 /** 108 108 * Property: imageOffset 109 * {<OpenLayers.Pixel>} For layers with a gutter, the image offset 109 * {<OpenLayers.Pixel>} For layers with a gutter, the image offset 110 110 * represents displacement due to the gutter. 111 111 */ … … 114 114 // OPTIONS 115 115 116 /** 116 /** 117 117 * Property: options 118 118 * {Object} An optional object whose properties will be set on the layer. … … 131 131 * half the size of the widest symbol that needs to be displayed. 132 132 * Defaults to zero. Non-tiled layers always have zero gutter. 133 */ 134 gutter: 0, 133 */ 134 gutter: 0, 135 135 136 136 /** … … 140 140 * maxResolution, and units if appropriate. Can be either a string or 141 141 * an <OpenLayers.Projection> object when created -- will be converted 142 * to an object when setMap is called if a string is passed. 143 */ 144 projection: null, 145 142 * to an object when setMap is called if a string is passed. 143 */ 144 projection: null, 145 146 146 /** 147 147 * APIProperty: units … … 170 170 */ 171 171 resolutions: null, 172 172 173 173 /** 174 174 * APIProperty: datetimeIntervals … … 179 179 */ 180 180 datetimeIntervals: null, 181 181 182 182 /** 183 183 * APIProperty: currentDateTime … … 194 194 */ 195 195 maxExtent: null, 196 196 197 197 /** 198 198 * APIProperty: minExtent … … 200 200 */ 201 201 minExtent: null, 202 202 203 203 /** 204 204 * APIProperty: maxResolution 205 205 * {Float} Default max is 360 deg / 256 px, which corresponds to 206 * zoom level 0 on gmaps. Specify a different value in the layer 207 * options if you are not using a geographic projection and 206 * zoom level 0 on gmaps. Specify a different value in the layer 207 * options if you are not using a geographic projection and 208 208 * displaying the whole world. 209 209 */ … … 221 221 */ 222 222 numZoomLevels: null, 223 223 224 224 /** 225 225 * APIProperty: minScale … … 227 227 */ 228 228 minScale: null, 229 229 230 230 /** 231 231 * APIProperty: maxScale … … 236 236 /** 237 237 * APIProperty: displayOutsideMaxExtent 238 * {Boolean} Request map tiles that are completely outside of the max 238 * {Boolean} Request map tiles that are completely outside of the max 239 239 * extent for this layer. Defaults to false. 240 240 */ … … 243 243 /** 244 244 * APIProperty: wrapDateLine 245 * {Boolean} #487 for more info. 245 * {Boolean} #487 for more info. 246 246 */ 247 247 wrapDateLine: false, 248 249 248 249 250 250 /** 251 251 * Constructor: OpenLayers.Layer … … 260 260 261 261 this.name = name; 262 262 263 263 if (this.id == null) { 264 264 … … 269 269 this.div.style.height = "100%"; 270 270 271 this.events = new OpenLayers.Events(this, this.div, 271 this.events = new OpenLayers.Events(this, this.div, 272 272 this.EVENT_TYPES); 273 273 } … … 277 277 } 278 278 }, 279 279 280 280 /** 281 281 * Method: destroy … … 305 305 this.events = null; 306 306 }, 307 307 308 308 /** 309 309 * Method: clone … … 316 316 */ 317 317 clone: function (obj) { 318 318 319 319 if (obj == null) { 320 320 obj = new OpenLayers.Layer(this.name, this.options); 321 } 322 321 } 322 323 323 // catch any randomly tagged-on properties 324 324 OpenLayers.Util.applyDefaults(obj, this); 325 325 326 326 // a cloned layer should never have its map property set 327 // because it has not been added to a map yet. 327 // because it has not been added to a map yet. 328 328 obj.map = null; 329 329 330 330 return obj; 331 331 }, 332 333 /** 332 333 /** 334 334 * APIMethod: setName 335 335 * Sets the new layer name for this layer. Can trigger a changelayer event … … 346 346 } 347 347 } 348 }, 349 348 }, 349 350 350 /** 351 351 * APIMethod: addOptions 352 * 352 * 353 353 * Parameters: 354 354 * newOptions - {Object} 355 355 */ 356 356 addOptions: function (newOptions) { 357 357 358 358 if (this.options == null) { 359 359 this.options = {}; 360 360 } 361 361 362 362 // update our copy for clone 363 363 OpenLayers.Util.extend(this.options, newOptions); … … 366 366 OpenLayers.Util.extend(this, newOptions); 367 367 }, 368 368 369 369 /** 370 370 * APIMethod: onMapResize … … 372 372 */ 373 373 onMapResize: function() { 374 //this function can be implemented by subclasses 374 //this function can be implemented by subclasses 375 375 }, 376 376 … … 402 402 /** 403 403 * Method: moveTo 404 * 404 * 405 405 * Parameters: 406 406 * bound - {<OpenLayers.Bounds>} … … 420 420 * Method: setMap 421 421 * Set the map property for the layer. This is done through an accessor 422 * so that subclasses can override this and take special action once 423 * they have their map variable set. 424 * 425 * Here we take care to bring over any of the necessary default 426 * properties from the map. 427 * 422 * so that subclasses can override this and take special action once 423 * they have their map variable set. 424 * 425 * Here we take care to bring over any of the necessary default 426 * properties from the map. 427 * 428 428 * Parameters: 429 429 * map - {<OpenLayers.Map>} … … 431 431 setMap: function(map) { 432 432 if (this.map == null) { 433 433 434 434 this.map = map; 435 435 436 436 // grab some essential layer data from the map if it hasn't already 437 437 // been set 438 438 this.maxExtent = this.maxExtent || this.map.maxExtent; 439 439 this.projection = this.projection || this.map.projection; 440 440 441 441 if (this.projection && typeof this.projection == "string") { 442 442 this.projection = new OpenLayers.Projection(this.projection); 443 443 } 444 444 445 445 // Check the projection to see if we can get units -- if not, refer 446 446 // to properties. 447 447 this.units = this.projection.getUnits() || 448 448 this.units || this.map.units; 449 449 450 450 this.initResolutions(); 451 451 452 452 if (!this.isBaseLayer) { 453 453 this.inRange = this.calculateInRange(); … … 455 455 this.div.style.display = show ? "" : "none"; 456 456 } 457 457 458 458 // deal with gutters 459 459 this.setTileSize(); 460 460 } 461 461 }, 462 462 463 463 /** 464 464 * APIMethod: removeMap 465 * Just as setMap() allows each layer the possibility to take a 465 * Just as setMap() allows each layer the possibility to take a 466 466 * personalized action on being added to the map, removeMap() allows 467 * each layer to take a personalized action on being removed from it. 467 * each layer to take a personalized action on being removed from it. 468 468 * For now, this will be mostly unused, except for the EventPane layer, 469 469 * which needs this hook so that it can remove the special invisible 470 * pane. 471 * 470 * pane. 471 * 472 472 * Parameters: 473 473 * map - {<OpenLayers.Map>} … … 476 476 //to be overridden by subclasses 477 477 }, 478 478 479 479 /** 480 480 * APIMethod: getImageSize 481 * 481 * 482 482 * Returns: 483 * {<OpenLayers.Size>} The size that the image should be, taking into 483 * {<OpenLayers.Size>} The size that the image should be, taking into 484 484 * account gutters. 485 */ 486 getImageSize: function() { 487 return (this.imageSize || this.tileSize); 488 }, 489 485 */ 486 getImageSize: function() { 487 return (this.imageSize || this.tileSize); 488 }, 489 490 490 /** 491 491 * APIMethod: setTileSize 492 492 * Set the tile size based on the map size. This also sets layer.imageSize 493 493 * and layer.imageOffset for use by Tile.Image. 494 * 494 * 495 495 * Parameters: 496 496 * size - {<OpenLayers.Size>} … … 508 508 // "gutters need non-null tile sizes"); 509 509 //} 510 this.imageOffset = new OpenLayers.Pixel(-this.gutter, 511 -this.gutter); 512 this.imageSize = new OpenLayers.Size(tileSize.w + (2*this.gutter), 513 tileSize.h + (2*this.gutter)); 510 this.imageOffset = new OpenLayers.Pixel(-this.gutter, 511 -this.gutter); 512 this.imageSize = new OpenLayers.Size(tileSize.w + (2*this.gutter), 513 tileSize.h + (2*this.gutter)); 514 514 } 515 515 }, … … 517 517 /** 518 518 * APIMethod: getVisibility 519 * 519 * 520 520 * Returns: 521 521 * {Boolean} The layer should be displayed (if in range). … … 525 525 }, 526 526 527 /** 527 /** 528 528 * APIMethod: setVisibility 529 * Set the visibility flag for the layer and hide/show & redraw 529 * Set the visibility flag for the layer and hide/show & redraw 530 530 * accordingly. Fire event unless otherwise specified 531 * 531 * 532 532 * Note that visibility is no longer simply whether or not the layer's 533 * style.display is set to "block". Now we store a 'visibility' state 534 * property on the layer class, this allows us to remember whether or 535 * not we *desire* for a layer to be visible. In the case where the 536 * map's resolution is out of the layer's range, this desire may be 533 * style.display is set to "block". Now we store a 'visibility' state 534 * property on the layer class, this allows us to remember whether or 535 * not we *desire* for a layer to be visible. In the case where the 536 * map's resolution is out of the layer's range, this desire may be 537 537 * subverted. 538 * 538 * 539 539 * Parameters: 540 540 * visible - {Boolean} Whether or not to display the layer (if in range) … … 552 552 }, 553 553 554 /** 554 /** 555 555 * APIMethod: display 556 556 * Hide or show the Layer 557 * 557 * 558 558 * Parameters: 559 559 * display - {Boolean} … … 567 567 /** 568 568 * Method: calculateInRange 569 * 569 * 570 570 * Returns: 571 571 * {Boolean} The layer is displayable at the current map's current … … 582 582 }, 583 583 584 /** 584 /** 585 585 * APIMethod: setIsBaseLayer 586 * 586 * 587 587 * Parameters: 588 588 * isBaseLayer - {Boolean} … … 602 602 /* */ 603 603 /********************************************************/ 604 605 /** 604 605 /** 606 606 * Method: initResolutions 607 * This method's responsibility is to set up the 'resolutions' array 607 * This method's responsibility is to set up the 'resolutions' array 608 608 * for the layer -- this array is what the layer will use to interface 609 * between the zoom levels of the map and the resolution display 609 * between the zoom levels of the map and the resolution display 610 610 * of the layer. 611 * 611 * 612 612 * The user has several options that determine how the array is set up. 613 * 614 * For a detailed explanation, see the following wiki from the 613 * 614 * For a detailed explanation, see the following wiki from the 615 615 * openlayers.org homepage: 616 616 * http://trac.openlayers.org/wiki/SettingZoomLevels … … 618 618 initResolutions: function() { 619 619 620 // These are the relevant options which are used for calculating 620 // These are the relevant options which are used for calculating 621 621 // resolutions information. 622 622 // … … 624 624 'projection', 'units', 625 625 'scales', 'resolutions', 626 'maxScale', 'minScale', 627 'maxResolution', 'minResolution', 626 'maxScale', 'minScale', 627 'maxResolution', 'minResolution', 628 628 'minExtent', 'maxExtent', 629 629 'numZoomLevels', 'maxZoomLevel' 630 630 ); 631 631 632 // First we create a new object where we will store all of the 632 // First we create a new object where we will store all of the 633 633 // resolution-related properties that we find in either the layer's 634 634 // 'options' array or from the map. 635 635 // 636 var confProps = {}; 636 var confProps = {}; 637 637 for(var i=0; i < props.length; i++) { 638 638 var property = props[i]; … … 654 654 } 655 655 656 // If numZoomLevels hasn't been set and the maxZoomLevel *has*, 656 // If numZoomLevels hasn't been set and the maxZoomLevel *has*, 657 657 // then use maxZoomLevel to calculate numZoomLevels 658 658 // … … 661 661 } 662 662 663 // First off, we take whatever hodge-podge of values we have and 663 // First off, we take whatever hodge-podge of values we have and 664 664 // calculate/distill them down into a resolutions[] array 665 665 // … … 670 670 for(var i = 0; i < confProps.scales.length; i++) { 671 671 var scale = confProps.scales[i]; 672 confProps.resolutions[i] = 673 OpenLayers.Util.getResolutionFromScale(scale, 672 confProps.resolutions[i] = 673 OpenLayers.Util.getResolutionFromScale(scale, 674 674 confProps.units); 675 675 } … … 682 682 // determine maxResolution 683 683 if (confProps.minScale) { 684 confProps.maxResolution = 685 OpenLayers.Util.getResolutionFromScale(confProps.minScale, 684 confProps.maxResolution = 685 OpenLayers.Util.getResolutionFromScale(confProps.minScale, 686 686 confProps.units); 687 687 } else if (confProps.maxResolution == "auto") { … … 690 690 var hRes = confProps.maxExtent.getHeight()/ viewSize.h; 691 691 confProps.maxResolution = Math.max(wRes, hRes); 692 } 692 } 693 693 694 694 // determine minResolution 695 if (confProps.maxScale != null) { 696 confProps.minResolution = 697 OpenLayers.Util.getResolutionFromScale(confProps.maxScale, 695 if (confProps.maxScale != null) { 696 confProps.minResolution = 697 OpenLayers.Util.getResolutionFromScale(confProps.maxScale, 698 698 confProps.units); 699 } else if ( (confProps.minResolution == "auto") && 699 } else if ( (confProps.minResolution == "auto") && 700 700 (confProps.minExtent != null) ) { 701 701 var viewSize = this.map.getSize(); … … 703 703 var hRes = confProps.minExtent.getHeight()/ viewSize.h; 704 704 confProps.minResolution = Math.max(wRes, hRes); 705 } 705 } 706 706 707 707 // determine numZoomLevels if not already set on the layer … … 709 709 this.options.numZoomLevels == undefined) { 710 710 var ratio = confProps.maxResolution / confProps.minResolution; 711 confProps.numZoomLevels = 711 confProps.numZoomLevels = 712 712 Math.floor(Math.log(ratio) / Math.log(2)) + 1; 713 713 } 714 715 // now we have numZoomLevels and maxResolution, 714 715 // now we have numZoomLevels and maxResolution, 716 716 // we can populate the resolutions array 717 717 confProps.resolutions = new Array(confProps.numZoomLevels); … … 736 736 } 737 737 } 738 738 739 739 //sort resolutions array ascendingly 740 740 // 741 741 confProps.resolutions.sort( function(a, b) { return(b-a); } ); 742 742 743 // now set our newly calculated values back to the layer 744 // Note: We specifically do *not* set them to layer.options, which we 745 // will preserve as it was when we added this layer to the map. 746 // this way cloned layers reset themselves to new map div 743 // now set our newly calculated values back to the layer 744 // Note: We specifically do *not* set them to layer.options, which we 745 // will preserve as it was when we added this layer to the map. 746 // this way cloned layers reset themselves to new map div 747 747 // dimensions) 748 748 // … … 752 752 var lastIndex = confProps.resolutions.length - 1; 753 753 this.minResolution = confProps.resolutions[lastIndex]; 754 754 755 755 this.scales = []; 756 756 for(var i = 0; i < confProps.resolutions.length; i++) { 757 this.scales[i] = 758 OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i], 757 this.scales[i] = 758 OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i], 759 759 confProps.units); 760 760 } 761 761 this.minScale = this.scales[0]; 762 762 this.maxScale = this.scales[this.scales.length - 1]; 763 763 764 764 this.numZoomLevels = confProps.numZoomLevels; 765 765 }, … … 767 767 /** 768 768 * APIMethod: getResolution 769 * 769 * 770 770 * Returns: 771 771 * {Float} The currently selected resolution of the map, taken from the … … 777 777 }, 778 778 779 /** 779 /** 780 780 * APIMethod: getExtent 781 * 781 * 782 782 * Returns: 783 * {<OpenLayers.Bounds>} A Bounds object which represents the lon/lat 783 * {<OpenLayers.Bounds>} A Bounds object which represents the lon/lat 784 784 * bounds of the current viewPort. 785 785 */ … … 793 793 /** 794 794 * APIMethod: getZoomForExtent 795 * 795 * 796 796 * Parameters: 797 797 * bounds - {<OpenLayers.Bounds>} 798 * closest - {Boolean} Find the zoom level that most closely fits the 799 * specified bounds. Note that this may result in a zoom that does 798 * closest - {Boolean} Find the zoom level that most closely fits the 799 * specified bounds. Note that this may result in a zoom that does 800 800 * not exactly contain the entire extent. 801 801 * Default is false. 802 802 * 803 803 * Returns: 804 * {Integer} The index of the zoomLevel (entry in the resolutions array) 805 * for the passed-in extent. We do this by calculating the ideal 806 * resolution for the given extent (based on the map size) and then 804 * {Integer} The index of the zoomLevel (entry in the resolutions array) 805 * for the passed-in extent. We do this by calculating the ideal 806 * resolution for the given extent (based on the map size) and then 807 807 * calling getZoomForResolution(), passing along the 'closest' 808 808 * parameter. … … 815 815 return this.getZoomForResolution(idealResolution, closest); 816 816 }, 817 818 /** 817 818 /** 819 819 * Method: getDataExtent 820 820 * Calculates the max extent which includes all of the data for the layer. 821 821 * This function is to be implemented by subclasses. 822 * 822 * 823 823 * Returns: 824 824 * {<OpenLayers.Bounds>} … … 830 830 /** 831 831 * APIMethod: getResolutionForZoom 832 * 832 * 833 833 * Parameter: 834 834 * zoom - {Float} 835 * 835 * 836 836 * Returns: 837 837 * {Float} A suitable resolution for the specified zoom. … … 853 853 /** 854 854 * APIMethod: getZoomForResolution 855 * 855 * 856 856 * Parameters: 857 857 * resolution - {Float} 858 * closest - {Boolean} Find the zoom level that corresponds to the absolute 858 * closest - {Boolean} Find the zoom level that corresponds to the absolute 859 859 * closest resolution, which may result in a zoom whose corresponding 860 860 * resolution is actually smaller than we would have desired (if this 861 861 * is being called from a getZoomForExtent() call, then this means that 862 * the returned zoom index might not actually contain the entire 862 * the returned zoom index might not actually contain the entire 863 863 * extent specified... but it'll be close). 864 864 * Default is false. 865 * 865 * 866 866 * Returns: 867 * {Integer} The index of the zoomLevel (entry in the resolutions array) 868 * that corresponds to the best fit resolution given the passed in 867 * {Integer} The index of the zoomLevel (entry in the resolutions array) 868 * that corresponds to the best fit resolution given the passed in 869 869 * value and the 'closest' specification. 870 870 */ … … 898 898 var diff; 899 899 var minDiff = Number.POSITIVE_INFINITY; 900 for(var i=0; i < this.resolutions.length; i++) { 900 for(var i=0; i < this.resolutions.length; i++) { 901 901 if (closest) { 902 902 diff = Math.abs(this.resolutions[i] - resolution); … … 915 915 return zoom; 916 916 }, 917 917 918 918 /** 919 919 * APIMethod: getLonLatFromViewPortPx 920 * 920 * 921 921 * Parameters: 922 922 * viewPortPx - {<OpenLayers.Pixel>} 923 923 * 924 924 * Returns: 925 * {<OpenLayers.LonLat>} An OpenLayers.LonLat which is the passed-in 925 * {<OpenLayers.LonLat>} An OpenLayers.LonLat which is the passed-in 926 926 * view port <OpenLayers.Pixel>, translated into lon/lat by the layer. 927 927 */ … … 933 933 if (center) { 934 934 var res = this.map.getResolution(); 935 935 936 936 var delta_x = viewPortPx.x - (size.w / 2); 937 937 var delta_y = viewPortPx.y - (size.h / 2); 938 938 939 939 lonlat = new OpenLayers.LonLat(center.lon + delta_x * res , 940 center.lat - delta_y * res); 940 center.lat - delta_y * res); 941 941 942 942 if (this.wrapDateLine) { … … 950 950 /** 951 951 * APIMethod: getViewPortPxFromLonLat 952 * 952 * 953 953 * Parameters: 954 954 * lonlat - {<OpenLayers.LonLat>} 955 955 * 956 * Returns: 957 * {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in 956 * Returns: 957 * {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in 958 958 * <OpenLayers.LonLat>,translated into view port pixels. 959 959 */ 960 960 getViewPortPxFromLonLat: function (lonlat) { 961 var px = null; 961 var px = null; 962 962 if (lonlat != null) { 963 963 var resolution = this.map.getResolution(); … … 966 966 Math.round(1/resolution * (lonlat.lon - extent.left)), 967 967 Math.round(1/resolution * (extent.top - lonlat.lat)) 968 ); 968 ); 969 969 } 970 970 return px; 971 971 }, <
