pass the position in as parameter on new tile creation. remove unnecessary setPosition() function, as tiles no longer really get moved. they get drawn in their div and then the div moves around. no need to make that any more complicated. update tests for that. Also, finish renaming 'grid' to 'layer' (from r369).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@390 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -66,7 +66,8 @@ OpenLayers.Layer.WFS.prototype =
|
|||||||
addTile:function(bounds, position) {
|
addTile:function(bounds, position) {
|
||||||
url = this.getFullRequestString(
|
url = this.getFullRequestString(
|
||||||
{ bbox:bounds.toBBOX() });
|
{ bbox:bounds.toBBOX() });
|
||||||
var tile = new OpenLayers.Tile.WFS(this, bounds, url, this.tileSize);
|
var tile = new OpenLayers.Tile.WFS(this, position, bounds,
|
||||||
|
url, this.tileSize);
|
||||||
tile.draw();
|
tile.draw();
|
||||||
return tile;
|
return tile;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ OpenLayers.Layer.WMS.prototype =
|
|||||||
{bbox:bounds.toBBOX(),
|
{bbox:bounds.toBBOX(),
|
||||||
width:this.tileSize.w,
|
width:this.tileSize.w,
|
||||||
height:this.tileSize.h});
|
height:this.tileSize.h});
|
||||||
var tile = new OpenLayers.Tile.Image(this, bounds, url, this.tileSize);
|
var tile = new OpenLayers.Tile.Image(this, position, bounds,
|
||||||
|
url, this.tileSize);
|
||||||
tile.draw();
|
tile.draw();
|
||||||
tile.setPosition(position);
|
|
||||||
this.div.appendChild(tile.img);
|
this.div.appendChild(tile.img);
|
||||||
return tile;
|
return tile;
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-11
@@ -30,15 +30,17 @@ OpenLayers.Tile.prototype = {
|
|||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Layer} layer
|
* @param {OpenLayers.Layer} layer
|
||||||
|
* @param {OpenLayers.Pixel} position
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {String} url
|
* @param {String} url
|
||||||
* @param {OpenLayers.Size} size
|
* @param {OpenLayers.Size} size
|
||||||
*/
|
*/
|
||||||
initialize: function(layer, bounds, url, size) {
|
initialize: function(layer, position, bounds, url, size) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
this.url = url;
|
this.position = position;
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
|
this.url = url;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -67,15 +69,6 @@ OpenLayers.Tile.prototype = {
|
|||||||
remove:function() {
|
remove:function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
/** This should be overridden by subclasses if they have special needs
|
|
||||||
*
|
|
||||||
* @param OpenLayers.Pixel
|
|
||||||
*/
|
|
||||||
setPosition:function(pixel) {
|
|
||||||
this.position = pixel;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type OpenLayers.Pixel
|
* @type OpenLayers.Pixel
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ OpenLayers.Tile.Image.prototype =
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Grid} grid
|
* @param {OpenLayers.Grid} layer
|
||||||
|
* @param {OpenLayers.Pixel} position
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {String} url
|
* @param {String} url
|
||||||
* @param {OpenLayers.Size} size
|
* @param {OpenLayers.Size} size
|
||||||
*/
|
*/
|
||||||
initialize: function(grid, bounds, url, size) {
|
initialize: function(layer, position, bounds, url, size) {
|
||||||
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -26,25 +27,12 @@ OpenLayers.Tile.Image.prototype =
|
|||||||
draw:function() {
|
draw:function() {
|
||||||
OpenLayers.Tile.prototype.draw.apply(this, arguments);
|
OpenLayers.Tile.prototype.draw.apply(this, arguments);
|
||||||
this.img = OpenLayers.Util.createImage(null,
|
this.img = OpenLayers.Util.createImage(null,
|
||||||
null,
|
this.position,
|
||||||
this.size,
|
this.size,
|
||||||
this.url,
|
this.url,
|
||||||
"absolute");
|
"absolute");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param OpenLayers.Pixel
|
|
||||||
*/
|
|
||||||
setPosition:function(pixel) {
|
|
||||||
OpenLayers.Tile.prototype.setPosition.apply(this, arguments);
|
|
||||||
|
|
||||||
//update the image's location
|
|
||||||
if (this.img) {
|
|
||||||
this.img.style.top = this.position.y + "px";
|
|
||||||
this.img.style.left = this.position.x + "px";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "OpenLayers.Tile.Image"
|
CLASS_NAME: "OpenLayers.Tile.Image"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ OpenLayers.Tile.WFS.prototype =
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Grid} grid
|
* @param {OpenLayers.Layer} layer
|
||||||
|
* @param {OpenLayers.Pixel} position
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {String} url
|
* @param {String} url
|
||||||
* @param {OpenLayers.Size} size
|
* @param {OpenLayers.Size} size
|
||||||
*/
|
*/
|
||||||
initialize: function(grid, bounds, url, size) {
|
initialize: function(layer, position, bounds, url, size) {
|
||||||
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
this.markers = new Array();
|
this.markers = new Array();
|
||||||
@@ -37,12 +38,6 @@ OpenLayers.Tile.WFS.prototype =
|
|||||||
this.loadFeaturesForRegion("requestSuccess");
|
this.loadFeaturesForRegion("requestSuccess");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param OpenLayers.Pixel
|
|
||||||
*/
|
|
||||||
setPosition:function(pixel) {
|
|
||||||
this.position = pixel;
|
|
||||||
},
|
|
||||||
|
|
||||||
/** get the full request string from the ds and the tile params
|
/** get the full request string from the ds and the tile params
|
||||||
* and call the AJAX loadURL().
|
* and call the AJAX loadURL().
|
||||||
|
|||||||
+14
-13
@@ -5,21 +5,22 @@
|
|||||||
var tile;
|
var tile;
|
||||||
|
|
||||||
function test_01_Tile_constructor (t) {
|
function test_01_Tile_constructor (t) {
|
||||||
t.plan( 9 );
|
t.plan( 6 );
|
||||||
tile = new OpenLayers.Tile(null,
|
|
||||||
new OpenLayers.Bounds(1,2,3,4),
|
var layer = new Object(); // bogus layer
|
||||||
"",
|
var position = new OpenLayers.Pixel(10,20);
|
||||||
new OpenLayers.Size(5,6) );
|
var bounds = new OpenLayers.Bounds(1,2,3,4);
|
||||||
|
var url = "bobob";
|
||||||
|
var size = new OpenLayers.Size(5,6);
|
||||||
|
|
||||||
|
tile = new OpenLayers.Tile(layer, position, bounds, url, size);
|
||||||
|
|
||||||
t.ok( tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object" );
|
t.ok( tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object" );
|
||||||
t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" );
|
t.eq( tile.layer, layer, "tile.layer set correctly");
|
||||||
t.eq( tile.bounds.left, 1, "tile.bounds.left is set correctly");
|
t.ok( tile.position.equals(position), "tile.position set correctly");
|
||||||
t.eq( tile.bounds.bottom, 2, "tile.bounds.bottom is set correctly");
|
t.ok( tile.bounds.equals(bounds), "tile.bounds set correctly");
|
||||||
t.eq( tile.bounds.right, 3, "tile.bounds.right is set correctly");
|
t.eq( tile.url, url, "tile.url set correctly");
|
||||||
t.eq( tile.bounds.top, 4, "tile.bounds.top is set correctly");
|
t.ok( tile.size.equals(size), "tile.size is set correctly" );
|
||||||
t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" );
|
|
||||||
t.eq( tile.size.w, 5, "tile.size.w is set correctly");
|
|
||||||
t.eq( tile.size.h, 6, "tile.size.h is set correctly");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+22
-32
@@ -6,28 +6,32 @@
|
|||||||
var tile;
|
var tile;
|
||||||
|
|
||||||
function test_01_Tile_Image_constructor (t) {
|
function test_01_Tile_Image_constructor (t) {
|
||||||
t.plan( 10 );
|
t.plan( 6 );
|
||||||
tile = new OpenLayers.Tile.Image(null,
|
|
||||||
new OpenLayers.Bounds(1,2,3,4),
|
var layer = new Object(); //bogus layer
|
||||||
"http://www.openlayers.org/dev/tests/tileimage",
|
var position = new OpenLayers.Pixel(20,30);
|
||||||
new OpenLayers.Size(5,6) );
|
var bounds = new OpenLayers.Bounds(1,2,3,4);
|
||||||
|
var url = "http://www.openlayers.org/dev/tests/tileimage";
|
||||||
|
var size = new OpenLayers.Size(5,6);
|
||||||
|
tile = new OpenLayers.Tile.Image(layer, position, bounds, url, size);
|
||||||
|
|
||||||
t.ok( tile instanceof OpenLayers.Tile.Image, "new OpenLayers.Tile returns Tile object" );
|
t.ok( tile instanceof OpenLayers.Tile.Image, "new OpenLayers.Tile returns Tile object" );
|
||||||
t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" );
|
t.eq( tile.layer, layer, "tile.layer is set correctly");
|
||||||
t.eq( tile.bounds.left, 1, "tile.bounds.left is set correctly");
|
t.ok( tile.position.equals(position), "tile.position is set correctly");
|
||||||
t.eq( tile.bounds.bottom, 2, "tile.bounds.bottom is set correctly");
|
t.ok( tile.bounds.equals(bounds), "tile.bounds is set correctly");
|
||||||
t.eq( tile.bounds.right, 3, "tile.bounds.right is set correctly");
|
t.eq( tile.url, url, "tile.url is set correctly");
|
||||||
t.eq( tile.bounds.top, 4, "tile.bounds.top is set correctly");
|
t.ok( tile.size.equals(size), "tile.size is set correctly");
|
||||||
t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" );
|
|
||||||
t.eq( tile.size.w, 5, "tile.size.w is set correctly");
|
|
||||||
t.eq( tile.size.h, 6, "tile.size.h is set correctly");
|
|
||||||
t.eq( tile.url, "http://www.openlayers.org/dev/tests/tileimage", "tile.size.h is set correctly");
|
|
||||||
}
|
}
|
||||||
function test_02_Tile_Image_draw (t) {
|
function test_02_Tile_Image_draw (t) {
|
||||||
t.plan( 4 );
|
t.plan( 4 );
|
||||||
tile = new OpenLayers.Tile.Image(null,
|
|
||||||
new OpenLayers.Bounds(1,2,3,4),
|
var layer = new Object(); //bogus layer
|
||||||
"http://www.openlayers.org/dev/tests/tileimage",
|
var position = new OpenLayers.Pixel(20,30);
|
||||||
new OpenLayers.Size(5,6));
|
var bounds = new OpenLayers.Bounds(1,2,3,4);
|
||||||
|
var url = "http://www.openlayers.org/dev/tests/tileimage";
|
||||||
|
var size = new OpenLayers.Size(5,6);
|
||||||
|
tile = new OpenLayers.Tile.Image(layer, position, bounds, url, size);
|
||||||
|
|
||||||
tile.draw();
|
tile.draw();
|
||||||
if (!isMozilla)
|
if (!isMozilla)
|
||||||
t.ok( true, "skipping element test outside of Mozilla");
|
t.ok( true, "skipping element test outside of Mozilla");
|
||||||
@@ -37,20 +41,6 @@
|
|||||||
t.eq( tile.img.style.width, "5px", "Image width is correct" );
|
t.eq( tile.img.style.width, "5px", "Image width is correct" );
|
||||||
t.eq( tile.img.style.height, "6px", "Image height is correct" );
|
t.eq( tile.img.style.height, "6px", "Image height is correct" );
|
||||||
}
|
}
|
||||||
function test_03_Tile_setPosition (t) {
|
|
||||||
t.plan( 5 );
|
|
||||||
tile = new OpenLayers.Tile.Image(
|
|
||||||
new OpenLayers.Bounds(1,2,3,4), "http://www.openlayers.org/dev/tests/tileimage",
|
|
||||||
new OpenLayers.Size(5,6));
|
|
||||||
t.eq( tile.getPosition(), null, "getPosition before draw returns null" );
|
|
||||||
tile.setPosition(new OpenLayers.Pixel(1,2));
|
|
||||||
t.eq( tile.getPosition().x, 1, "tile's x position set correctly " );
|
|
||||||
t.eq( tile.getPosition().y, 2, "tile's y position set correctly" );
|
|
||||||
tile.draw();
|
|
||||||
tile.setPosition(new OpenLayers.Pixel(1,2));
|
|
||||||
t.eq( tile.img.style.left, 1 + "px", "setPosition sets x of image correctly after draw" );
|
|
||||||
t.eq( tile.img.style.top, 2 + "px", "setPosition sets y of image correctly after draw" );
|
|
||||||
}
|
|
||||||
|
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user