(Closes #982), comment/documentation/requires changes (Closes #983, #993, #988), Fixing post support in proxy.cgi (Closes #991), baseLayer zoom level change (Closes #990), typo in Layer.Image.setURL (Closes #985), and a fix or the Layer.Google bug caused by Google's changing internals (#994). RC2, here we come. git-svn-id: http://svn.openlayers.org/branches/openlayers/2.5@4390 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
118 lines
6.0 KiB
HTML
118 lines
6.0 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(7);
|
|
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();
|
|
|
|
// 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");
|
|
layer.setUrl('http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=-180,-90,0,90&WIDTH=256&HEIGHT=256');
|
|
t.eq(layer.tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=-180,-90,0,90&WIDTH=256&HEIGHT=256", "URL is correct after setURL");
|
|
}
|
|
/******
|
|
*
|
|
*
|
|
* 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_before_use (t) {
|
|
t.plan(1);
|
|
var map = new OpenLayers.Map('map');
|
|
layer = new OpenLayers.Layer.Image('Test', '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.removeLayer(layer);
|
|
layer.destroy();
|
|
t.ok(true, "destroy() didn't throw an error");
|
|
}
|
|
|
|
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>
|