Merge pull request #52 from fredj/deprecated.js
Move deprecated code into deprecated.js, r=ahocevar
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
|
||||
|
||||
function test_Layer_Grid_getTilesBounds(t) {
|
||||
t.plan( 4 );
|
||||
t.plan(3);
|
||||
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
|
||||
@@ -110,10 +110,6 @@
|
||||
|
||||
t.ok( bounds.equals(testBounds), "getTilesBounds() returns correct bounds");
|
||||
|
||||
var bounds = layer.getGridBounds();
|
||||
|
||||
t.ok( bounds.equals(testBounds), "getGridBounds() wrapper works the same as getTilesBounds.");
|
||||
|
||||
//no tiles
|
||||
layer.grid = [];
|
||||
bounds = layer.getTilesBounds();
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!-- multimap api key for http://(www.)openlayers.org -->
|
||||
<script type="text/javascript" src="http://developer.multimap.com/API/maps/1.2/OA10072915821139765"></script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var doTest = true;
|
||||
function test_Layer_MultiMap_constructor (t) {
|
||||
// WebKit browsers fail when the API key is for a different url, so we
|
||||
// do not test in this case.
|
||||
try {
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.MultiMap('MultiMap Layer');
|
||||
map.addLayer(layer);
|
||||
}
|
||||
catch(e) {
|
||||
doTest = false;
|
||||
}
|
||||
|
||||
if (!doTest) { t.plan(0); return; }
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.MultiMap('MultiMap Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
|
||||
t.ok( layer instanceof OpenLayers.Layer.MultiMap, "new OpenLayers.Layer.MultiMap returns object" );
|
||||
t.eq( layer.CLASS_NAME, "OpenLayers.Layer.MultiMap", "CLASS_NAME variable set correctly");
|
||||
|
||||
t.eq( layer.name, "MultiMap Layer", "layer.name is correct" );
|
||||
|
||||
t.ok ( layer.mapObject != null, "MultiMap Object correctly loaded");
|
||||
}
|
||||
|
||||
function test_Layer_MultiMap_isBaseLayer (t) {
|
||||
if (!doTest) { t.plan(0); return; }
|
||||
t.plan(1);
|
||||
|
||||
var layer = new OpenLayers.Layer.MultiMap('MultiMap Layer');
|
||||
|
||||
t.ok(layer.isBaseLayer, "a default load of multimap layer responds as a base layer");
|
||||
}
|
||||
|
||||
function test_Layer_MultiMap_Translation_lonlat (t) {
|
||||
if (!doTest) { t.plan(0); return; }
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.MultiMap('MultiMap Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
// these two lines specify an appropriate translation.
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var gLatLng = new MMLatLon(50,100);
|
||||
var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
|
||||
|
||||
|
||||
olLonLat = layer.getOLLonLatFromMapObjectLonLat(gLatLng);
|
||||
t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
|
||||
|
||||
var transGLatLng = layer.getMapObjectLonLatFromOLLonLat(olLonLat);
|
||||
t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
|
||||
|
||||
t.ok( layer.getMapObjectLonLatFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
|
||||
t.ok( layer.getOLLonLatFromMapObjectLonLat(null) == null, "getOLLonLatFromGLatLng(null) returns null");
|
||||
}
|
||||
|
||||
function test_Layer_MultiMap_Translation_pixel (t) {
|
||||
if (!doTest) { t.plan(0); return; }
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.MultiMap('MultiMap Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
// these two lines specify an appropriate translation.
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var gPoint = new MMPoint(50,100);
|
||||
var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
|
||||
|
||||
|
||||
olPixel = layer.getOLPixelFromMapObjectPixel(gPoint);
|
||||
t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
|
||||
|
||||
var transGPoint = layer.getMapObjectPixelFromOLPixel(olPixel);
|
||||
t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
|
||||
|
||||
t.ok( layer.getMapObjectPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
|
||||
t.ok( layer.getOLPixelFromMapObjectPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
|
||||
}
|
||||
|
||||
|
||||
function test_Layer_destroy (t) {
|
||||
if (!doTest) { t.plan(0); return; }
|
||||
t.plan( 5 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
layer = new OpenLayers.Layer.MultiMap('Test Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
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" );
|
||||
t.eq( layer.multimap, null, "layer.gmap is null after destroy" );
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,177 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var name = "Vector Layer";
|
||||
|
||||
function test_Layer_WFS_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var layer = new OpenLayers.Layer.WFS(name, "url", {});
|
||||
t.ok(layer instanceof OpenLayers.Layer.WFS, "new OpenLayers.Layer.Vector returns correct object" );
|
||||
t.eq(layer.name, name, "layer name is correctly set");
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_WFS_getDataExtent(t) {
|
||||
t.plan(1);
|
||||
|
||||
var layer = new OpenLayers.Layer.WFS(name, "url", {});
|
||||
layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 0)));
|
||||
layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1)));
|
||||
t.eq(layer.getDataExtent().toBBOX(), "0,0,0,1", "bbox is correctly pulled from vectors.");
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_WFS_setOpacity(t) {
|
||||
t.plan(3);
|
||||
|
||||
var layer = new OpenLayers.Layer.WFS(name, "url", {});
|
||||
layer.setOpacity(.5);
|
||||
t.eq(layer.opacity, 0.5, "vector setOpacity didn't fail");
|
||||
var layer = new OpenLayers.Layer.WFS(name, "url", {}, {'featureClass': OpenLayers.Feature.WFS});
|
||||
var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0));
|
||||
marker.setOpacity = function() {
|
||||
t.ok(true, "Marker setOpacity was called");
|
||||
}
|
||||
layer.addMarker(marker);
|
||||
layer.setOpacity(.6);
|
||||
t.eq(layer.opacity, 0.6, "setOpacity didn't fail on markers");
|
||||
}
|
||||
|
||||
function test_Layer_WFS_destroy(t) {
|
||||
t.plan(13);
|
||||
|
||||
var tVectorDestroy = OpenLayers.Layer.Vector.prototype.destroy;
|
||||
OpenLayers.Layer.Vector.prototype.destroy = function() {
|
||||
g_VectorDestroyed = true;
|
||||
}
|
||||
|
||||
var tMarkersDestroy = OpenLayers.Layer.Markers.prototype.destroy;
|
||||
OpenLayers.Layer.Markers.prototype.destroy = function() {
|
||||
g_MarkersDestroyed = true;
|
||||
}
|
||||
|
||||
var layer = {
|
||||
'vectorMode': true,
|
||||
'tile': {
|
||||
'destroy': function() {
|
||||
t.ok(true, "wfs layer's tile is destroyed");
|
||||
}
|
||||
},
|
||||
'ratio': {},
|
||||
'featureClass': {},
|
||||
'format': {},
|
||||
'formatObject': {
|
||||
'destroy': function() {
|
||||
t.ok(true, "wfs layer's format object is destroyed");
|
||||
}
|
||||
},
|
||||
'formatOptions': {},
|
||||
'encodeBBOX': {},
|
||||
'extractAttributes': {}
|
||||
};
|
||||
|
||||
//this call should set off two tests (destroys for tile and format object)
|
||||
g_VectorDestroyed = null;
|
||||
g_MarkersDestroyed = null;
|
||||
OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []);
|
||||
|
||||
t.ok(g_VectorDestroyed && !g_MarkersDestroyed, "when vector mode is set to true, the default vector layer's destroy() method is called");
|
||||
t.eq(layer.vectorMode, null, "'vectorMode' property nullified");
|
||||
t.eq(layer.tile, null, "'tile' property nullified");
|
||||
t.eq(layer.ratio, null, "'ratio' property nullified");
|
||||
t.eq(layer.featureClass, null, "'featureClass' property nullified");
|
||||
t.eq(layer.format, null, "'format' property nullified");
|
||||
t.eq(layer.formatObject, null, "'formatObject' property nullified");
|
||||
t.eq(layer.formatOptions, null, "'formatOptions' property nullified");
|
||||
t.eq(layer.encodeBBOX, null, "'encodeBBOX' property nullified");
|
||||
t.eq(layer.extractAttributes, null, "'extractAttributes' property nullified");
|
||||
|
||||
layer.vectorMode = false;
|
||||
|
||||
//this call will *not* set off two tests (tile and format object are null)
|
||||
g_VectorDestroyed = null;
|
||||
g_MarkersDestroyed = null;
|
||||
OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []);
|
||||
t.ok(!g_VectorDestroyed && g_MarkersDestroyed, "when vector mode is set to false, the default markers layer's destroy() method is called");
|
||||
|
||||
OpenLayers.Layer.Vector.prototype.destroy = tVectorDestroy;
|
||||
OpenLayers.Layer.Markers.prototype.destroy = tMarkersDestroy;
|
||||
}
|
||||
|
||||
function test_Layer_WFS_mapresizevector(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(new OpenLayers.Layer.WMS("WMS", "url", {}));
|
||||
var layer = new OpenLayers.Layer.WFS(name, "url", {});
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
map.addLayer(layer);
|
||||
setSize = false;
|
||||
layer.renderer.setSize = function() { setSize = true; }
|
||||
layer.onMapResize();
|
||||
t.eq(setSize, true, "Renderer resize called on map size change.");
|
||||
map.destroy();
|
||||
|
||||
}
|
||||
function test_Layer_WFS_drawmap(t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||
map.addLayer(layer);
|
||||
|
||||
layer = new OpenLayers.Layer.WFS( "Owl Survey",
|
||||
"http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?",
|
||||
{typename: "OWLS", maxfeatures: 10},
|
||||
{ featureClass: OpenLayers.Feature.WFS});
|
||||
map.addLayer(layer);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
try {
|
||||
map.setCenter(new OpenLayers.LonLat(-100, 60), 3);
|
||||
} catch (Exception) {
|
||||
}
|
||||
t.eq(layer.tile.url, "http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?TYPENAME=OWLS&MAXFEATURES=10&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A4326&BBOX=-187.890625,-36.6796875,-12.109375,156.6796875", "Tile URL is set correctly when not encoded");
|
||||
map.destroy();
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'}
|
||||
);
|
||||
map.addLayer(layer);
|
||||
|
||||
layer = new OpenLayers.Layer.WFS( "Owl Survey",
|
||||
"http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?",
|
||||
{typename: "OWLS", maxfeatures: 10},
|
||||
{ featureClass: OpenLayers.Feature.WFS, 'encodeBBOX': true});
|
||||
map.addLayer(layer);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
try {
|
||||
map.setCenter(new OpenLayers.LonLat(-100, 60), 3);
|
||||
} catch (Exception) {
|
||||
}
|
||||
t.eq(layer.tile.url, "http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?TYPENAME=OWLS&MAXFEATURES=10&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A4326&BBOX=-187.890625%2C-36.679687%2C-12.109375%2C156.679688", "Tile URL is set correctly when not encoded");
|
||||
map.destroy();
|
||||
}
|
||||
function test_projection_srs(t) {
|
||||
t.plan(1);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(new OpenLayers.Layer("",{isBaseLayer: true} ));
|
||||
// we use an empty moveTo function because we don't want to request tiles
|
||||
var layer = new OpenLayers.Layer.WFS("","/wfs",{},{'projection': new OpenLayers.Projection("EPSG:900913"),
|
||||
moveTo: function() {}});
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
var params = OpenLayers.Util.getParameters(layer.getFullRequestString());
|
||||
t.eq(params.SRS, "EPSG:900913", "SRS represents projection of WFS layer, instead of map (#1537)");
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user