Multimap now conforms to other EventPane subclasses in expected behavior for

some functions, and has tests available, so when I break it at some point, 
hopefully I'll know :)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1389 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-08-27 01:46:09 +00:00
parent 0c1caaf717
commit ef00010111
4 changed files with 139 additions and 3 deletions

View File

@@ -237,7 +237,8 @@ OpenLayers.Layer.MultiMap.prototype =
* @type int
*/
getOLZoomFromMMZoom: function(mmZoom) {
return mmZoom - 1;
if (mmZoom) return mmZoom - 1;
return null;
},
/**
@@ -248,7 +249,8 @@ OpenLayers.Layer.MultiMap.prototype =
* @type int
*/
getMMZoomFromOLZoom: function(olZoom) {
return olZoom + 1;
if (olZoom) return olZoom + 1;
return null;
},
//
@@ -326,6 +328,11 @@ OpenLayers.Layer.MultiMap.prototype =
return pixel;
},
destroy: function() {
this.multimap = null;
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MultiMap"
});

View File

@@ -19,6 +19,7 @@
<li>test_Layer_KaMap.html</li>
<li>test_Layer_WMS.html</li>
<li>test_Layer_Google.html</li>
<li>test_Layer_MultiMap.html</li>
<li>test_Tile.html</li>
<li>test_Tile_Image.html</li>
<li>test_Control.html</li>

View File

@@ -785,7 +785,7 @@ Test.AnotherWay._set_iframe_location=function( iframe, loc, outside_path_correct
Test.AnotherWay._start_loading_page=function()
{
var test_page=Test.AnotherWay._g_tests_queue[0];
test_page.loading_timeout_milliseconds=2000;
test_page.loading_timeout_milliseconds=4000;
test_page.timeout_id=setTimeout( Test.AnotherWay._loading_timeout, Test.AnotherWay._g_timeout_granularity );
test_page.wait_msg=Test.AnotherWay._print_counter_result( test_page.url, "loading...", test_page.loading_timeout_milliseconds, "loading" );
if( test_page.convention=="jsan" ) {

View File

@@ -0,0 +1,128 @@
<html>
<head>
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var layer;
function test_01_Layer_MultiMap_constructor (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog 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, "Goog Layer", "layer.name is correct" );
t.ok ( layer.multimap != null, "MultiMap Object correctly loaded");
}
function test_02_Layer_MultiMap_isBaseLayer (t) {
t.plan(1);
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
}
function test_03_Layer_MultiMap_Translation_zoom (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog 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 gZoom = 5;
var correspondingOLZoom = 4;
olZoom = layer.getOLZoomFromMMZoom(gZoom);
t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
t.eq(layer.getMMZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
t.ok( layer.getMMZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
t.ok( layer.getOLZoomFromMMZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
}
function test_04_Layer_MultiMap_Translation_lonlat (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog 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.getOLLonLatFromMMLatLong(gLatLng);
t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
var transGLatLng = layer.getMMLatLongFromOLLonLat(olLonLat);
t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
t.ok( layer.getMMLatLongFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
t.ok( layer.getOLLonLatFromMMLatLong(null) == null, "getOLLonLatFromGLatLng(null) returns null");
}
function test_05_Layer_MultiMap_Translation_pixel (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog 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.getOLPixelFromPixel(gPoint);
t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
var transGPoint = layer.getPixelFromOLPixel(olPixel);
t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
t.ok( layer.getPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
t.ok( layer.getOLPixelFromPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
}
function test_99_Layer_destroy (t) {
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>