bringing all changes from sandbox/euzuro/LayersReworking down into the trunk. this is a merge of r656:HEAD http://svn.openlayers.org/sandbox/euzuro/LayersReworking
git-svn-id: http://svn.openlayers.org/trunk/openlayers@806 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -30,25 +30,35 @@
|
||||
t.plan( 7 );
|
||||
var evt = {which: 1}; // control expects left-click
|
||||
map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
|
||||
control = new OpenLayers.Control.PanZoom();
|
||||
map.addControl(control,
|
||||
new OpenLayers.Pixel(20,20));
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 4);
|
||||
var res = map.getResolution();
|
||||
map.addControl(control, new OpenLayers.Pixel(20,20));
|
||||
|
||||
var centerLL = new OpenLayers.LonLat(0,0);
|
||||
map.setCenter(centerLL, 5);
|
||||
|
||||
control.buttons[0].onmousedown(evt);
|
||||
t.eq( map.getCenter().lat, res*50, "Pan up works correctly" );
|
||||
t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" );
|
||||
|
||||
control.buttons[1].onmousedown(evt);
|
||||
t.eq( map.getCenter().lon, res*-50, "Pan left works correctly" );
|
||||
t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" );
|
||||
|
||||
control.buttons[2].onmousedown(evt);
|
||||
t.eq( map.getCenter().lon, 0, "Pan right works correctly" );
|
||||
t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" );
|
||||
|
||||
control.buttons[3].onmousedown(evt);
|
||||
t.eq( map.getCenter().lat, 0, "Pan down works correctly" );
|
||||
control.buttons[4].onmousedown(evt);
|
||||
t.ok( map.getCenter().lat == centerLL.lat, "Pan down works correctly" );
|
||||
|
||||
control.buttons[4].onmousedown(evt);
|
||||
t.eq( map.getZoom(), 6, "zoomin works correctly" );
|
||||
|
||||
control.buttons[6].onmousedown(evt);
|
||||
t.eq( map.getZoom(), 5, "zoomout works correctly" );
|
||||
control.buttons[4].onmousedown(evt);
|
||||
|
||||
control.buttons[5].onmousedown(evt);
|
||||
t.eq( map.getZoom(), 2, "zoomworld works correctly" );
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
function test_02_Control_PanZoomBar_addControl (t) {
|
||||
t.plan( 8 );
|
||||
map = new OpenLayers.Map('map', {controls:[]});
|
||||
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
control = new OpenLayers.Control.PanZoomBar();
|
||||
t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" );
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
function test_01_Layer_Text_constructor (t) {
|
||||
t.plan( 6 );
|
||||
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', 'data_Layer_Text_textfile.txt');
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
|
||||
t.ok( layer instanceof OpenLayers.Layer.Text, "new OpenLayers.Layer.Text returns object" );
|
||||
t.eq( layer.location, "data_Layer_Text_textfile.txt", "layer.location is correct" );
|
||||
var markers;
|
||||
@@ -22,11 +22,15 @@
|
||||
function test_02_Layer_Text_draw (t) {
|
||||
// t.plan(5);
|
||||
t.plan( 2 );
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', 'data_Layer_Text_textfile.txt');
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
|
||||
t.ok( layer instanceof OpenLayers.Layer.Text, "new OpenLayers.Layer.Text returns object" );
|
||||
var map = new OpenLayers.Map('map');
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
map.addLayer(layer);
|
||||
t.eq( map.layers[0].name, layer.name, "Layer added to map okay" );
|
||||
t.eq( map.layers[1].name, layer.name, "Layer added to map okay" );
|
||||
t.delay_call( 1, function() {
|
||||
map.setCenter(new OpenLayers.LonLat(0,0),0);
|
||||
|
||||
@@ -43,8 +47,12 @@
|
||||
}
|
||||
function test_03_Layer_Text_events (t) {
|
||||
t.plan( 4 );
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', 'data_Layer_Text_textfile.txt');
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
|
||||
var map = new OpenLayers.Map('map');
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0),0);
|
||||
var event = {};
|
||||
|
||||
+54
-10
@@ -5,10 +5,15 @@
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var map;
|
||||
function test_01_Map_constructor (t) {
|
||||
t.plan( 10 );
|
||||
t.plan( 9 );
|
||||
|
||||
map = new OpenLayers.Map('map'); // no longer need to call $(), constructor does it
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map returns object" );
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map returns object" );
|
||||
if (!isMozilla) {
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
@@ -21,17 +26,19 @@
|
||||
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" );
|
||||
t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
|
||||
t.ok( map.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" );
|
||||
}
|
||||
function test_02_Map_center(t) {
|
||||
t.plan(5);
|
||||
t.plan(4);
|
||||
map = new OpenLayers.Map($('map'));
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
map.setCenter(new OpenLayers.LonLat(2,1), 0);
|
||||
t.ok( map.getCenter() instanceof OpenLayers.LonLat, "map.getCenter returns a LonLat");
|
||||
t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter");
|
||||
t.eq( map.getResolution(), map.maxResolution, "map.getResolution() == map.maxResolution");
|
||||
t.eq( map.getCenter().lon, 2, "map center lon is correct after calling setCenter");
|
||||
t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter");
|
||||
}
|
||||
@@ -59,8 +66,12 @@
|
||||
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hash" );
|
||||
}
|
||||
function test_05_Map_center(t) {
|
||||
t.plan(7);
|
||||
t.plan(5);
|
||||
map = new OpenLayers.Map($('map'));
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"} );
|
||||
map.addLayer(baseLayer);
|
||||
map.setCenter(new OpenLayers.LonLat(2, 1), 0);
|
||||
map.zoomIn();
|
||||
t.eq( map.getZoom(), 1, "map.zoom is correct after calling setCenter,zoom in");
|
||||
@@ -68,18 +79,26 @@
|
||||
t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter,zoom in");
|
||||
map.zoomOut();
|
||||
t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter,zoom in, zoom out");
|
||||
|
||||
map.zoomTo(5);
|
||||
t.eq( map.getZoom(), 5, "map.zoom is correct after calling zoomTo" );
|
||||
map.zoomToFullExtent();
|
||||
/**
|
||||
map.zoomToMaxExtent();
|
||||
t.eq( map.getZoom(), 2, "map.zoom is correct after calling zoomToFullExtent" );
|
||||
var lonlat = map.getCenter();
|
||||
var zero = new OpenLayers.LonLat(0, 0);
|
||||
t.ok( lonlat.equals(zero), "map center is correct after calling zoomToFullExtent" );
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
function test_06_Map_zoomend_event (t) {
|
||||
t.plan(3);
|
||||
t.plan(2);
|
||||
map = new OpenLayers.Map('map');
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
map.events.register("zoomend", {count: 0}, function() {
|
||||
this.count++;
|
||||
t.ok(true, "zoomend event was triggered " + this.count + " times");
|
||||
@@ -93,6 +112,10 @@
|
||||
t.plan(4);
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
|
||||
var popup = new OpenLayers.Popup("chicken",
|
||||
new OpenLayers.LonLat(0,0),
|
||||
@@ -127,9 +150,16 @@
|
||||
t.ok(!found, "popup.div successfully removed from the map's viewPort");
|
||||
}
|
||||
|
||||
/*** THIS IS A GOOD TEST, BUT IT SHOULD BE MOVED TO WMS.
|
||||
* Also, it won't work until we figure out the viewSize bug
|
||||
|
||||
function test_08_Map_px_lonlat_translation (t) {
|
||||
t.plan( 6 );
|
||||
map = new OpenLayers.Map($('map'));
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(baseLayer);
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||
|
||||
var pixel = new OpenLayers.Pixel(50,150);
|
||||
@@ -153,6 +183,20 @@
|
||||
|
||||
t.ok( newPixel.equals(pixel), "2nd translation to pixel and back to lonlat is consistent");
|
||||
}
|
||||
*/
|
||||
function test_09_Map_isValidLonLat(t) {
|
||||
t.plan( 3 );
|
||||
map = new OpenLayers.Map($('map'));
|
||||
layer = 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" } );
|
||||
map.addLayer(layer);
|
||||
|
||||
t.ok( !map.isValidLonLat(null), "null lonlat is not valid" );
|
||||
t.ok( map.isValidLonLat(new OpenLayers.LonLat(33862, 717606)), "lonlat outside max extent is valid" );
|
||||
t.ok( !map.isValidLonLat(new OpenLayers.LonLat(10, 10)), "lonlat outside max extent is not valid" );
|
||||
}
|
||||
|
||||
function test_99_Map_destroy (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
Reference in New Issue
Block a user