git-svn-id: http://svn.openlayers.org/trunk/openlayers@57 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
68 lines
3.3 KiB
HTML
68 lines
3.3 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript"><!--
|
|
var map;
|
|
function test_01_Map_constructor (t) {
|
|
t.plan( 12 );
|
|
|
|
map = new OpenLayers.Map('map'); // no longer need to call $(), constructor does it
|
|
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map returns object" );
|
|
t.ok( map.div instanceof HTMLDivElement, "map.div is an HTMLDivElement" );
|
|
t.ok( map.controlDiv instanceof HTMLDivElement, "map.controlDiv is an HTMLDivElement" );
|
|
t.ok( map.viewPortDiv instanceof HTMLDivElement, "map.viewPortDiv is an HTMLDivElement" );
|
|
t.ok( map.layerContainerDiv instanceof HTMLDivElement, "map.layerContainerDiv is an HTMLDivElement" );
|
|
t.ok( map.layerContainerDiv instanceof HTMLDivElement, "map.layerContainerDiv is an HTMLDivElement" );
|
|
t.ok( map.layers instanceof Array, "map.layers is an Array" );
|
|
t.ok( map.controls instanceof Array, "map.controls is an Array" );
|
|
t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" );
|
|
t.ok( map.maxExtent instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
|
|
t.ok( map.maxZoomLevel > 0, "map.maxZoomLevel is set" );
|
|
t.ok( map.maxResolution > 0, "map.maxResolution is set" );
|
|
}
|
|
function test_02_Map_center(t) {
|
|
t.plan(4);
|
|
map = new OpenLayers.Map($('map'));
|
|
map.setCenter(new OpenLayers.LatLon(1,2), 3);
|
|
t.ok( map.getCenter() instanceof OpenLayers.LatLon, "map.getCenter returns a LatLon");
|
|
t.eq( map.getZoom(), 3, "map.zoom is correct after calling setCenter");
|
|
t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter");
|
|
t.eq( map.getCenter().lon, 2, "map center lon is correct after calling setCenter");
|
|
}
|
|
function test_03_Map_add_layers(t) {
|
|
t.plan(4);
|
|
map = new OpenLayers.Map($('map'));
|
|
var layer1 = new OpenLayers.Layer.WMS("Layer 1",
|
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
|
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
|
var layer2 = new OpenLayers.Layer.WMS("Layer 2",
|
|
"http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"});
|
|
// this uses map.addLayer internally
|
|
map.addLayers([layer1, layer2])
|
|
t.eq( map.layers.length, 2, "map has exactly two layers" );
|
|
t.ok( map.layers[0] === layer1, "1st layer is layer1" );
|
|
t.ok( map.layers[1] === layer2, "2nd layer is layer2" );
|
|
t.eq( parseInt(layer1.div.style.zIndex), map.Z_INDEX_BASE['Layer'],
|
|
"layer1 zIndex is set" );
|
|
}
|
|
function test_04_Map_options(t) {
|
|
t.plan(2);
|
|
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 3.14159});
|
|
t.eq( map.maxZoomLevel, 5, "map.maxZoomLevel set correctly via options hash" );
|
|
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hash" );
|
|
}
|
|
function test_99_Map_destroy (t) {
|
|
t.plan( 2 );
|
|
map = new OpenLayers.Map($('map'));
|
|
map.destroy();
|
|
t.eq( map.layers, null, "map.layers is null after destroy" );
|
|
t.eq( map.controls, null, "map.controls is null after destroy" );
|
|
}
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width: 1024px; height: 512px;"/>
|
|
</body>
|
|
</html>
|