Changeset 2134
- Timestamp:
- 01/10/07 00:11:02 (2 years ago)
- Files:
-
- sandbox/tschaub/gutter/examples/gutter.html (added)
- sandbox/tschaub/gutter/lib/OpenLayers/Layer.js (modified) (1 diff)
- sandbox/tschaub/gutter/lib/OpenLayers/Layer/WMS.js (modified) (2 diffs)
- sandbox/tschaub/gutter/lib/OpenLayers/Tile/Image.js (modified) (7 diffs)
- sandbox/tschaub/gutter/tests/test_Layer_WMS.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/gutter/lib/OpenLayers/Layer.js
r2133 r2134 545 545 this.opacity = opacity; 546 546 for(var i=0; i<this.div.childNodes.length; ++i) { 547 var element = this.div.childNodes[i] ;547 var element = this.div.childNodes[i].firstChild; 548 548 OpenLayers.Util.modifyDOMElement(element, null, null, null, 549 549 null, null, null, opacity); sandbox/tschaub/gutter/lib/OpenLayers/Layer/WMS.js
r2133 r2134 24 24 25 25 reproject: true, 26 27 /** Determines the width (in pixels) of the gutter around image tiles 28 * to ignore. By setting this property to a non-zero value, images 29 * will be requested that are wider and taller than the tile size by 30 * a value of 2 x gutter. This allows artifacts of rendering at tile 31 * edges to be ignored. Set a gutter value that is equal to half the size 32 * of the widest symbol that needs to be displayed. Defaults to zero. 33 * 34 * @type int 35 */ 36 gutter: 0, 26 37 27 38 /** … … 93 104 */ 94 105 getURL: function (bounds) { 106 if(!this.gutter) { 107 return this.getFullRequestString( 108 {BBOX:bounds.toBBOX(), 109 WIDTH:this.tileSize.w, 110 HEIGHT:this.tileSize.h}); 111 } 112 var tileMapLT = new OpenLayers.LonLat(bounds.left, bounds.top); 113 var tileMapRB = new OpenLayers.LonLat(bounds.right, bounds.bottom); 114 var tilePixelLT = this.getViewPortPxFromLonLat(tileMapLT); 115 var tilePixelRB = this.getViewPortPxFromLonLat(tileMapRB); 116 var imagePixelLT = new OpenLayers.Pixel(tilePixelLT.x - this.gutter, 117 tilePixelLT.y - this.gutter); 118 var imagePixelRB = new OpenLayers.Pixel(tilePixelRB.x + this.gutter, 119 tilePixelRB.y + this.gutter); 120 var imageMapLT = this.getLonLatFromViewPortPx(imagePixelLT); 121 var imageMapRB = this.getLonLatFromViewPortPx(imagePixelRB); 122 var imageBounds = new OpenLayers.Bounds(imageMapLT.lon, imageMapRB.lat, 123 imageMapRB.lon, imageMapLT.lat); 95 124 return this.getFullRequestString( 96 {BBOX: bounds.toBBOX(),97 WIDTH:this.tileSize.w ,98 HEIGHT:this.tileSize.h });125 {BBOX:imageBounds.toBBOX(), 126 WIDTH:this.tileSize.w + (2 * this.gutter), 127 HEIGHT:this.tileSize.h + (2 * this.gutter)}); 99 128 }, 100 129 sandbox/tschaub/gutter/lib/OpenLayers/Tile/Image.js
r2133 r2134 15 15 /** @type DOMElement img */ 16 16 imgDiv: null, 17 18 /** The image element is appended to the frame. Any gutter on the image 19 * will be hidden behind the frame. 20 * 21 * @type DOMElement div */ 22 frame: null, 17 23 18 24 /** … … 27 33 initialize: function(layer, position, bounds, url, size) { 28 34 OpenLayers.Tile.prototype.initialize.apply(this, arguments); 35 this.frame = document.createElement('div'); 36 this.frame.style.overflow = 'hidden'; 37 this.frame.style.position = 'absolute'; 38 if(layer.gutter) { 39 this.imageOffset = new OpenLayers.Pixel(-layer.gutter, -layer.gutter); 40 this.imageSize = new OpenLayers.Size(this.size.w + (2 * layer.gutter), 41 this.size.h + (2 * layer.gutter)); 42 } else { 43 this.imageOffset = new OpenLayers.Pixel(0, 0); 44 this.imageSize = this.size.clone(); 45 } 29 46 }, 30 47 … … 33 50 */ 34 51 destroy: function() { 35 if ((this.imgDiv != null) && (this.imgDiv.parentNode == this. layer.div)) {36 this. layer.div.removeChild(this.imgDiv);52 if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.frame)) { 53 this.frame.removeChild(this.imgDiv); 37 54 } 38 55 this.imgDiv = null; 56 if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) { 57 this.layer.div.removeChild(this.frame); 58 } 59 this.frame = null; 39 60 OpenLayers.Tile.prototype.destroy.apply(this, arguments); 40 61 }, … … 55 76 56 77 this.url = this.layer.getURL(this.bounds); 57 78 // position the frame 79 OpenLayers.Util.modifyDOMElement(this.frame, 80 null, this.position, this.size); 58 81 if (this.layer.alpha) { 59 82 OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, 60 null, this.position, this.size, this.url);83 null, null, this.imageSize, this.url); 61 84 } else { 62 85 this.imgDiv.src = this.url; 63 86 OpenLayers.Util.modifyDOMElement(this.imgDiv, 64 null, this.position, this.size) ;87 null, null, this.imageSize) ; 65 88 } 66 89 this.drawn = true; … … 97 120 if (this.layer.alpha) { 98 121 this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 99 this. position,100 this. size,122 this.imageOffset, 123 this.imageSize, 101 124 null, 102 " absolute",125 "relative", 103 126 null, 104 127 null, … … 107 130 } else { 108 131 this.imgDiv = OpenLayers.Util.createImage(null, 109 this. position,110 this. size,132 this.imageOffset, 133 this.imageSize, 111 134 null, 112 " absolute",135 "relative", 113 136 null, 114 137 null, … … 124 147 this.checkImgURL.bindAsEventListener(this) ); 125 148 126 this.layer.div.appendChild(this.imgDiv); 149 this.frame.appendChild(this.imgDiv); 150 this.layer.div.appendChild(this.frame); 151 127 152 if(this.layer.opacity != null) { 128 153 sandbox/tschaub/gutter/tests/test_Layer_WMS.html
r2133 r2134 51 51 url + "?" + OpenLayers.Util.getParameterString(tParams), 52 52 "image src is created correctly via addtile" ); 53 t.eq( tile. imgDiv.style.top, "6px", "image top is set correctly via addtile" );54 t.eq( tile. imgDiv.style.left, "5px", "image top is set correctly via addtile" );55 56 var firstChild = layer.div.firstChild ;53 t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" ); 54 t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" ); 55 56 var firstChild = layer.div.firstChild.firstChild; 57 57 if (!isMozilla) 58 58 t.ok( true, "skipping element test outside of Mozilla"); … … 182 182 map.zoomToMaxExtent(); 183 183 t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); 184 t.eq(parseFloat(tLayer.div.firstChild. style.opacity), 0.5, "Opacity on tile is correct");184 t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); 185 185 tLayer.setOpacity("0.6"); 186 186 t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); 187 t.eq(parseFloat(tLayer.div.firstChild. style.opacity), 0.6, "Opacity on tile is changed correctly");187 t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); 188 188 var pixel = new OpenLayers.Pixel(5,6); 189 189 var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
