Changeset 1737
- Timestamp:
- 10/25/06 19:05:23 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Image.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Image.js
r1721 r1737 2 2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 3 3 * for the full text of the license. */ 4 4 5 /** 5 6 * @fileoverview Image Layer … … 16 17 OpenLayers.Class.inherit(OpenLayers.Layer, { 17 18 18 /** @type String */ 19 name: null, 20 19 /** By default, Layer.Image will be a baselayer 20 * 21 * @type Boolean */ 22 isBaseLayer: true, 23 21 24 /** @type String */ 22 25 url: null, … … 28 31 size: null, 29 32 30 /** @type Object */31 options: null,32 33 33 /** @type OpenLayers.Tile.Image */ 34 34 tile: null, 35 35 36 /** 37 * The ratio of height/width represented by a single pixel in the graphic 36 /** The ratio of height/width represented by a single pixel in the graphic 38 37 * 39 38 * @type Float */ … … 53 52 this.extent = extent; 54 53 this.size = size; 54 OpenLayers.Layer.prototype.initialize.apply(this, [name, options]); 55 55 56 this.aspectRatio = (this.extent.getHeight() / this.size.h) / 56 57 (this.extent.getWidth() / this.size.w); 57 OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);58 59 // unless explicitly set in options, the layer will be a base layer60 if((options == null) || (options.isBaseLayer == null)) {61 this.isBaseLayer = true;62 }63 58 }, 64 59 … … 97 92 98 93 /** 99 * This is a bad method to have here. It would be nicer to be able100 * to ask Layer directly.101 */102 shouldCalcResolutions: function() {103 var props = new Array(104 'scales', 'resolutions',105 'maxScale', 'minScale',106 'maxResolution', 'minResolution',107 'minExtent', 'maxExtent',108 'numZoomLevels', 'maxZoomLevel'109 );110 for(var i=0; i < props.length; i++) {111 var property = props[i];112 if(this.options[property] != null) {113 return false;114 }115 }116 return true;117 },118 119 120 /**121 94 * @param {OpenLayers.Map} map 122 95 */ … … 124 97 // If nothing to do with resolutions has been set, assume a single 125 98 // resolution determined by extent/size 126 if( this.shouldCalcResolutions()) {127 this.options.resolutions = [this.extent.getWidth() / this.size.w];99 if( this.options.maxResolution == null ) { 100 this.options.maxResolution = this.extent.getWidth() / this.size.w; 128 101 } 129 102 OpenLayers.Layer.prototype.setMap.apply(this, arguments); 130 103 }, 131 104 132 /** When zooming or first rendering, create a new tile for the image.105 /** Create the tile for the image or resize it for the new resolution 133 106 * 134 107 * @param {OpenLayers.Bounds} bounds … … 143 116 if(zoomChanged || firstRendering) { 144 117 145 //clear out the old tile146 if(this.tile) {147 this.tile.destroy();148 this.tile = null;149 }150 151 //determine new tile bounds152 var tileBounds = this.extent.clone();153 154 118 //determine new tile size 155 119 var tileWidth = this.extent.getWidth() / this.map.getResolution(); … … 159 123 160 124 //determine new position (upper left corner of new bounds) 161 var ul = new OpenLayers.LonLat(t ileBounds.left, tileBounds.top);162 var pos= this.map.getLayerPxFromLonLat(ul);125 var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top); 126 var ulPx = this.map.getLayerPxFromLonLat(ul); 163 127 164 this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds, 165 this.url, tileSize); 128 if(firstRendering) { 129 //create the new tile 130 this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent, 131 this.url, tileSize); 132 } else { 133 //just resize the tile and set it's new position 134 this.tile.size = tileSize.clone(); 135 this.tile.position = ulPx.clone(); 136 } 166 137 this.tile.draw(); 167 138 } … … 173 144 setUrl: function(newUrl) { 174 145 this.url = newUrl; 175 this. moveTo();146 this.draw(); 176 147 }, 177 148 178 /** 149 /** The url we return is always the same (the image itself never changes) 150 * so we can ignore the bounds parameter (it will always be the same, 151 * anyways) 152 * 179 153 * @param {OpenLayers.Bounds} bounds 180 154 */
