svn merge trunk/openlayers/@2999 trunk/openlayers/@HEAD branches/openlayers/2.4/ git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
109 lines
5.3 KiB
HTML
109 lines
5.3 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript"><!--
|
|
var layer;
|
|
|
|
function test_01_Layer_Image_constructor (t) {
|
|
t.plan( 13 );
|
|
|
|
var options = { chicken: 151, foo: "bar", projection: "none" };
|
|
var layer = new OpenLayers.Layer.Image('Test Layer',
|
|
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
|
|
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
|
|
new OpenLayers.Size(580, 288), options);
|
|
|
|
t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
|
|
t.eq( layer.CLASS_NAME, "OpenLayers.Layer.Image", "CLASS_NAME variable set correctly");
|
|
|
|
t.eq( layer.name, "Test Layer", "layer.name is correct" );
|
|
t.ok( layer.id != null, "Layer is given an id");
|
|
t.eq( layer.projection, "none", "default layer projection correctly set");
|
|
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
|
|
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
|
|
|
|
options.chicken = 552;
|
|
|
|
t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
|
|
|
|
t.eq( layer.isBaseLayer, true, "Default img layer is base layer" );
|
|
|
|
layer = new OpenLayers.Layer.Image('Test Layer',
|
|
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
|
|
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
|
|
new OpenLayers.Size(580, 288));
|
|
t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
|
|
t.eq( layer.name, "Test Layer", "layer.name is correct" );
|
|
t.ok( layer.projection == null, "default layer projection correctly set");
|
|
t.ok( layer.options instanceof Object, "layer.options correctly initialized as a non-null Object" );
|
|
}
|
|
|
|
function test_50_Layer_Image_tileTests (t) {
|
|
t.plan(9);
|
|
var map = new OpenLayers.Map('map');
|
|
|
|
layer = new OpenLayers.Layer.Image('Test Layer',
|
|
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
|
|
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
|
|
new OpenLayers.Size(580, 288));
|
|
|
|
map.addLayer(layer);
|
|
map.zoomToMaxExtent();
|
|
t.ok(layer.imageSize, "layer.imageSize is set");
|
|
t.ok(layer.tileSize, "layer.tileSize is set");
|
|
t.ok(layer.tileSize.equals(layer.imageSize), "tileSize equals imageSize");
|
|
|
|
// no resolution info was sent, so maxResolution should be calculated
|
|
// by aspectRatio*extent/size (this is the pixel aspect ratio)
|
|
var aspectRatio = (layer.extent.getHeight() / layer.size.h) /
|
|
(layer.extent.getWidth() / layer.size.w);
|
|
t.eq(aspectRatio, layer.aspectRatio, "aspectRatio is properly set");
|
|
var maxExtent = aspectRatio * layer.extent.getWidth() / layer.size.w;
|
|
t.eq(maxExtent, layer.maxResolution, "maxResolution is properly set");
|
|
|
|
t.eq(layer.tile.position.x,-42, "Tile x positioned correctly at maxextent");
|
|
t.eq(layer.tile.position.y,106, "Tile y positioned correctly at maxextent");
|
|
t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
|
|
map.zoomIn();
|
|
t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
|
|
}
|
|
/******
|
|
*
|
|
*
|
|
* HERE IS WHERE SOME TESTS SHOULD BE PUT TO CHECK ON THE LONLAT-PX TRANSLATION
|
|
* FUNCTIONS AND RESOLUTION AND GETEXTENT GETZOOMLEVEL, ETC
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
function test_99_Layer_Image_destroy (t) {
|
|
t.plan( 4 );
|
|
|
|
var map = new OpenLayers.Map('map');
|
|
|
|
layer = new OpenLayers.Layer.Image('Test Layer',
|
|
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
|
|
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
|
|
new OpenLayers.Size(580, 288));
|
|
|
|
map.addLayer(layer);
|
|
map.zoomToMaxExtent();
|
|
|
|
layer.destroy();
|
|
|
|
t.eq( layer.name, null, "layer.name is null after destroy" );
|
|
t.eq( layer.div, null, "layer.div is null after destroy" );
|
|
t.eq( layer.map, null, "layer.map is null after destroy" );
|
|
t.eq( layer.options, null, "layer.options is null after destroy" );
|
|
|
|
}
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width:500px;height:500px"></div>
|
|
<div id="map2" style="width:100px;height:100px"></div>
|
|
</body>
|
|
</html>
|