Changeset 1198
- Timestamp:
- 08/12/06 11:54:51 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Tile.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Tile/Image.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Tile/WFS.js (modified) (4 diffs)
- trunk/openlayers/tests/test_Tile_Image.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Tile.js
r1149 r1198 32 32 * @type OpenLayers.Pixel */ 33 33 position:null, 34 35 /** @type Boolean */ 36 drawn: false, 34 37 35 38 /** … … 67 70 */ 68 71 draw:function() { 72 this.drawn = true; 69 73 }, 70 71 redraw: function () { 72 this.draw(); 73 }, 74 74 75 75 /** 76 76 * @param {OpenLayers.Bounds} 77 77 * @param {OpenLayers.pixel} position 78 * @param {Boolean} redraw Redraw tile after moving? 79 * Default is true 78 80 */ 79 moveTo: function (bounds, position) { 81 moveTo: function (bounds, position, redraw) { 82 if (redraw == null) { 83 redraw = true; 84 } 85 86 this.clear(); 80 87 this.bounds = bounds.clone(); 81 88 this.position = position.clone(); 82 this.redraw(); 89 if (redraw) { 90 this.draw(); 91 } 83 92 }, 84 85 93 86 94 /** Clear the tile of any bounds/position-related data so that it can … … 88 96 */ 89 97 clear: function() { 90 this.bounds = null; 91 this.position = null; 98 this.drawn = false; 92 99 }, 93 100 94 /**95 * @type OpenLayers.Pixel96 */97 getPosition: function() {98 return this.position;99 },100 101 101 /** @final @type String */ 102 102 CLASS_NAME: "OpenLayers.Tile" trunk/openlayers/lib/OpenLayers/Tile/Image.js
r1155 r1198 2 2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full 3 3 * text of the license. */ 4 4 5 // @require: OpenLayers/Tile.js 6 5 7 /** 6 8 * @class … … 25 27 OpenLayers.Tile.prototype.initialize.apply(this, arguments); 26 28 }, 27 29 30 /** 31 * 32 */ 28 33 destroy: function() { 29 34 if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.layer.div)) { … … 35 40 36 41 /** 37 */ 42 * 43 */ 38 44 draw:function() { 39 if (this.layer.alpha) { 40 this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 41 this.position, 42 this.size, 43 this.url, 44 "absolute", 45 null, 46 null, 47 true); 48 } else { 49 this.imgDiv = OpenLayers.Util.createImage(null, 50 this.position, 51 this.size, 52 this.url, 53 "absolute", 54 null, 55 true); 45 OpenLayers.Tile.prototype.draw.apply(this, arguments); 46 47 if (this.imgDiv == null) { 48 this.initImgDiv(); 56 49 } 57 this.layer.div.appendChild(this.imgDiv);58 },59 50 60 /** Clear the tile of any bounds/position-related data so that it can61 * be reused in a new location.62 */63 clear: function() {64 this.imgDiv.style.display = "none";65 },66 67 /**68 * @param {OpenLayers.Bounds}69 * @param {OpenLayers.pixel} position70 */71 moveTo: function (bounds, position) {72 this.url = this.layer.getURL(bounds);73 OpenLayers.Tile.prototype.moveTo.apply(this, arguments);74 },75 76 redraw: function () {77 51 this.imgDiv.style.display = "none"; 78 52 if (this.layer.alpha) { … … 86 60 }, 87 61 62 /** Clear the tile of any bounds/position-related data so that it can 63 * be reused in a new location. 64 */ 65 clear: function() { 66 OpenLayers.Tile.prototype.clear.apply(this, arguments); 67 this.imgDiv.style.display = "none"; 68 }, 69 70 /** 71 * @param {OpenLayers.Bounds} 72 * @param {OpenLayers.pixel} position 73 * @param {Boolean} redraw 74 */ 75 moveTo: function (bounds, position, redraw) { 76 this.url = this.layer.getURL(bounds); 77 OpenLayers.Tile.prototype.moveTo.apply(this, arguments); 78 }, 79 80 /** 81 * 82 */ 83 initImgDiv: function() { 84 if (this.layer.alpha) { 85 this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 86 this.position, 87 this.size, 88 null, 89 "absolute", 90 null, 91 null, 92 true); 93 } else { 94 this.imgDiv = OpenLayers.Util.createImage(null, 95 this.position, 96 this.size, 97 null, 98 "absolute", 99 null, 100 true); 101 } 102 this.layer.div.appendChild(this.imgDiv); 103 }, 104 88 105 /** @final @type String */ 89 106 CLASS_NAME: "OpenLayers.Tile.Image" trunk/openlayers/lib/OpenLayers/Tile/WFS.js
r1189 r1198 40 40 */ 41 41 destroy: function() { 42 this.clear(); 42 OpenLayers.Tile.prototype.destroy.apply(this, arguments); 43 this.destroyAllFeatures(); 44 this.features = null; 43 45 this.urls = null; 44 OpenLayers.Tile.prototype.destroy.apply(this, arguments);45 46 }, 46 47 … … 49 50 */ 50 51 clear: function() { 51 while(this.features.length > 0) { 52 var feature = this.features.shift(); 53 feature.destroy(); 54 } 52 OpenLayers.Tile.prototype.clear.apply(this, arguments); 53 this.destroyAllFeatures(); 55 54 }, 56 55 57 56 /** 58 */ 57 * 58 */ 59 59 draw:function() { 60 if (this.drawn) { 61 this.clear(); 62 } 63 OpenLayers.Tile.prototype.draw.apply(this, arguments); 60 64 this.loadFeaturesForRegion(this.requestSuccess); 61 65 }, 62 66 63 /**64 * @param {OpenLayers.Bounds}65 * @param {OpenLayers.pixel} position66 */67 moveTo: function (bounds, position) {68 69 this.loaded = false;70 71 OpenLayers.Tile.prototype.moveTo.apply(this, arguments);72 },73 74 67 /** get the full request string from the ds and the tile params 75 68 * and call the AJAX loadURL(). … … 82 75 loadFeaturesForRegion:function(success, failure) { 83 76 84 if ( !this.loaded) {77 if (this.urls != null) { 85 78 86 if (this.urls != null) { 87 88 // TODO: Hmmm, this stops multiple loads of the data when a 89 // result isn't immediately retrieved, but it's hacky. 90 // Do it better. 91 this.loaded = true; 92 93 for(var i=0; i < this.urls.length; i++) { 94 var params ={ BBOX:bounds.toBBOX() }; 95 var url = this.urls[i] + 96 OpenLayers.Util.getParameterString(params); 97 OpenLayers.loadURL(url, null, this, 98 success, failure); 99 } 79 for(var i=0; i < this.urls.length; i++) { 80 var params = { BBOX:bounds.toBBOX() }; 81 var url = this.urls[i] + 82 OpenLayers.Util.getParameterString(params); 83 OpenLayers.loadURL(url, null, this, success, failure); 100 84 } 101 85 } … … 122 106 */ 123 107 addResults: function(results) { 124 125 108 for (var i=0; i < results.length; i++) { 126 127 109 var feature = new this.layer.featureClass(this.layer, 128 110 results[i]); 129 111 this.features.push(feature); 130 112 } 131 132 113 }, 133 114 115 /** Iterate through and call destroy() on each feature, removing it from 116 * the local array 117 * 118 * @private 119 */ 120 destroyAllFeatures: function() { 121 while(this.features.length > 0) { 122 var feature = this.features.shift(); 123 feature.destroy(); 124 } 125 }, 126 134 127 /** @final @type String */ 135 128 CLASS_NAME: "OpenLayers.Tile.WFS" trunk/openlayers/tests/test_Tile_Image.html
r688 r1198 9 9 t.plan( 6 ); 10 10 11 var layer = new Object(); //bogus layer 11 var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 12 "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); 13 12 14 var position = new OpenLayers.Pixel(20,30); 13 15 var bounds = new OpenLayers.Bounds(1,2,3,4); … … 17 19 18 20 t.ok( tile instanceof OpenLayers.Tile.Image, "new OpenLayers.Tile returns Tile object" ); 19 t. eq( tile.layer,layer, "tile.layer is set correctly");21 t.ok( tile.layer == layer, "tile.layer is set correctly"); 20 22 t.ok( tile.position.equals(position), "tile.position is set correctly"); 21 23 t.ok( tile.bounds.equals(bounds), "tile.bounds is set correctly");
