new layerswitcher, improved google layer, boxes layer, grid fix
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1096 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<li>test_Tile.html</li>
|
||||
<li>test_Tile_Image.html</li>
|
||||
<li>test_Control.html</li>
|
||||
<li>test_Control_LayerSwitcher.html</li>
|
||||
<li>test_Control_PanZoom.html</li>
|
||||
<li>test_Control_PanZoomBar.html</li>
|
||||
<li>test_Control_Permalink.html</li>
|
||||
|
||||
@@ -32,6 +32,7 @@ body { height: 98%; font: normal normal 10pt sans-serif }
|
||||
#col1 { float: left; width: 27em; margin: 0 0 0 1em; overflow: visible; }
|
||||
#col2 { position: relative; height: 98%; margin: 0 0.5em 0 27em; }
|
||||
#col1_header { margin-top: 0.5em; }
|
||||
#scroller { height: 550px; overflow: auto;}
|
||||
#testtable { margin: 0 0 2em 0; width: 97%; }
|
||||
#run_buttons { margin-bottom: 4em; }
|
||||
|
||||
@@ -2286,8 +2287,10 @@ onload=function()
|
||||
|
||||
<div id="col1">
|
||||
<div id="col1_header">Test pages:</div>
|
||||
<div id="scroller">
|
||||
<table id="testtable">
|
||||
</table>
|
||||
</div>
|
||||
<div id="run_buttons">
|
||||
<input type="button" value=" clear " id="clear_btn" />
|
||||
<input type="button" value=" run all " id="run_all" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<script type="text/javascript"><!--
|
||||
var bounds;
|
||||
function test_01_Bounds_constructor (t) {
|
||||
t.plan( 14 );
|
||||
t.plan( 12 );
|
||||
bounds = new OpenLayers.Bounds(0,2,10,4);
|
||||
t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
|
||||
t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
|
||||
@@ -19,14 +19,13 @@
|
||||
t.eq( sz.w, 10, "bounds.getSize() has correct width value" );
|
||||
t.eq( sz.h, 2, "bounds.getSize() has correct height value" );
|
||||
|
||||
var center = bounds.getCenterPixel();
|
||||
t.eq( center.x, 5, "bounds.getCenterPixel() has correct x value" );
|
||||
t.eq( center.y, 3, "bounds.getCenterPixel() has correct y value" );
|
||||
|
||||
var center = bounds.getCenterLonLat();
|
||||
t.eq( center.lon, 5, "bounds.getCenterLonLat() has correct lon value" );
|
||||
t.eq( center.lat, 3, "bounds.getCenterLonLat() has correct lat value" );
|
||||
var center = new OpenLayers.Pixel(5,3);
|
||||
var boundsCenter = bounds.getCenterPixel();
|
||||
t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
|
||||
|
||||
var center = new OpenLayers.LonLat(5,3);
|
||||
var boundsCenter = bounds.getCenterLonLat();
|
||||
t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
|
||||
}
|
||||
|
||||
function test_02_Bounds_toBBOX(t) {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
|
||||
function test_01_Control_LayerSwitcher_constructor (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
control = new OpenLayers.Control.LayerSwitcher();
|
||||
t.ok( control instanceof OpenLayers.Control.LayerSwitcher, "new OpenLayers.Control.LayerSwitcher returns object" );
|
||||
}
|
||||
|
||||
function test_02_Control_LayerSwitcher_draw (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
control = new OpenLayers.Control.LayerSwitcher();
|
||||
map.addControl(control);
|
||||
|
||||
var div = control.draw();
|
||||
t.ok( control.div != null, "draw makes a div" );
|
||||
t.ok( div != null, "draw returns its div" );
|
||||
}
|
||||
|
||||
function test_03_Control_LayerSwitcher_loadContents(t) {
|
||||
|
||||
t.plan( 5 );
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("WMS",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
control = new OpenLayers.Control.LayerSwitcher();
|
||||
map.addControl(control);
|
||||
|
||||
t.ok(control.layersDiv != null, "correctly makes layers div");
|
||||
t.ok(control.baseLayersDiv != null, "correctly makes layers div");
|
||||
t.ok(control.dataLayersDiv != null, "correctly makes layers div");
|
||||
|
||||
t.ok(control.maximizeDiv != null, "correctly makes resize div");
|
||||
t.ok(control.minimizeDiv != null, "correctly makes resize div");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function test_04_Control_LayerSwitcher_redraw (t) {
|
||||
|
||||
t.plan( 8 );
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("WMS",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
control = new OpenLayers.Control.LayerSwitcher();
|
||||
map.addControl(control);
|
||||
|
||||
|
||||
var wmsInput = $("input_" + layer.name);
|
||||
t.ok(wmsInput != null, "correctly makes an input for wms layer");
|
||||
t.eq(wmsInput.type, "radio", "wms correctly made a radio button");
|
||||
t.eq(wmsInput.name, "baseLayers", "wms correctly named");
|
||||
t.eq(wmsInput.value, layer.name, "wms correctly valued");
|
||||
|
||||
var markersInput = $("input_" + markers.name);
|
||||
t.ok(markersInput != null, "correctly makes an input for markers layer");
|
||||
t.eq(markersInput.type, "checkbox", "wms correctly made a radio button");
|
||||
t.eq(markersInput.name, markers.name, "wms correctly named");
|
||||
t.eq(markersInput.value, markers.name, "wms correctly valued");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
|
||||
|
||||
t.eq( layer.isBaseLayer(), false, "Default layer is not base layer" );
|
||||
t.eq( layer.isBaseLayer, false, "Default layer is not base layer" );
|
||||
|
||||
layer = new OpenLayers.Layer('Test Layer');
|
||||
t.ok( layer instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
|
||||
|
||||
@@ -23,17 +23,11 @@
|
||||
}
|
||||
|
||||
function test_02_Layer_Google_isBaseLayer (t) {
|
||||
t.plan(2);
|
||||
t.plan(1);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
t.ok(layer.isBaseLayer(), "a default load of google layer responds as a base layer");
|
||||
|
||||
layer.gmap = null;
|
||||
|
||||
t.ok(!layer.isBaseLayer(), "a bad load of google layer does not respond as a base layer");
|
||||
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
|
||||
}
|
||||
|
||||
function test_03_Layer_Google_Translation_zoom (t) {
|
||||
@@ -48,7 +42,7 @@
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var gZoom = 5;
|
||||
var correspondingOLZoom = 4;
|
||||
var correspondingOLZoom = 5;
|
||||
|
||||
|
||||
olZoom = layer.getOLZoomFromGZoom(gZoom);
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0));
|
||||
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
//grab a reference to one of the tiles
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
@@ -43,11 +43,6 @@
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0));
|
||||
|
||||
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
//grab a reference to one of the tiles
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
|
||||
@@ -99,16 +99,12 @@
|
||||
|
||||
function test_05_Layer_WMS_isBaseLayer(t) {
|
||||
|
||||
t.plan(2);
|
||||
t.plan(1);
|
||||
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
|
||||
t.ok( layer.isBaseLayer(), "baselayer is true when no transparent set");
|
||||
|
||||
layer.params.TRANSPARENT = "true";
|
||||
|
||||
t.ok( !layer.isBaseLayer(), "baselayer is false when transparent set");
|
||||
t.ok( layer.isBaseLayer, "baselayer is true by default");
|
||||
}
|
||||
|
||||
function test_06_Layer_WMS_mergeNewParams (t) {
|
||||
|
||||
@@ -223,6 +223,37 @@
|
||||
t.ok( gotLayer == null, "getLayer correctly returns null when layer not found");
|
||||
}
|
||||
|
||||
function test_10_Map_setBaseLayer(t) {
|
||||
t.plan( 4 );
|
||||
|
||||
map = new OpenLayers.Map($('map'));
|
||||
|
||||
var wmslayer = new OpenLayers.Layer.WMS('Test Layer',
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv",
|
||||
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'},
|
||||
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
|
||||
|
||||
var wmslayer2 = new OpenLayers.Layer.WMS('Test Layer2',
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv",
|
||||
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'},
|
||||
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
|
||||
|
||||
map.addLayers([wmslayer, wmslayer2]);
|
||||
|
||||
t.ok(map.baseLayer == wmslayer, "default base layer is first one added");
|
||||
|
||||
map.setBaseLayer(null);
|
||||
t.ok(map.baseLayer == wmslayer, "setBaseLayer on null object does nothing (and does not break)");
|
||||
|
||||
map.setBaseLayer("chicken");
|
||||
t.ok(map.baseLayer == wmslayer, "setBaseLayer on non-layer object does nothing (and does not break)");
|
||||
|
||||
map.setBaseLayer(wmslayer2);
|
||||
t.ok(map.baseLayer == wmslayer2, "setbaselayer correctly sets 'baseLayer' property");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function test_99_Map_destroy (t) {
|
||||
t.plan( 2 );
|
||||
map = new OpenLayers.Map($('map'));
|
||||
|
||||
Reference in New Issue
Block a user