3 <script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
4 <script src="../../lib/OpenLayers.js"></script>
5 <script type="text/javascript">
8 function test_Layer_MultiMap_constructor (t) {
11 var map = new OpenLayers.Map('map');
12 var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
16 t.ok( layer instanceof OpenLayers.Layer.MultiMap, "new OpenLayers.Layer.MultiMap returns object" );
17 t.eq( layer.CLASS_NAME, "OpenLayers.Layer.MultiMap", "CLASS_NAME variable set correctly");
19 t.eq( layer.name, "Goog Layer", "layer.name is correct" );
21 t.ok ( layer.mapObject != null, "MultiMap Object correctly loaded");
24 function test_Layer_MultiMap_isBaseLayer (t) {
27 var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
29 t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
32 function test_Layer_MultiMap_Translation_lonlat (t) {
36 var map = new OpenLayers.Map('map');
37 var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
40 // these two lines specify an appropriate translation.
41 // the code afterwards works by itself to test that translation
42 // works correctly both ways.
43 var gLatLng = new MMLatLon(50,100);
44 var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
47 olLonLat = layer.getOLLonLatFromMapObjectLonLat(gLatLng);
48 t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
50 var transGLatLng = layer.getMapObjectLonLatFromOLLonLat(olLonLat);
51 t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
53 t.ok( layer.getMapObjectLonLatFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
54 t.ok( layer.getOLLonLatFromMapObjectLonLat(null) == null, "getOLLonLatFromGLatLng(null) returns null");
57 function test_Layer_MultiMap_Translation_pixel (t) {
61 var map = new OpenLayers.Map('map');
62 var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
65 // these two lines specify an appropriate translation.
66 // the code afterwards works by itself to test that translation
67 // works correctly both ways.
68 var gPoint = new MMPoint(50,100);
69 var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
72 olPixel = layer.getOLPixelFromMapObjectPixel(gPoint);
73 t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
75 var transGPoint = layer.getMapObjectPixelFromOLPixel(olPixel);
76 t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
78 t.ok( layer.getMapObjectPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
79 t.ok( layer.getOLPixelFromMapObjectPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
83 function test_Layer_destroy (t) {
86 var map = new OpenLayers.Map('map');
88 layer = new OpenLayers.Layer.MultiMap('Test Layer');
93 t.eq( layer.name, null, "layer.name is null after destroy" );
94 t.eq( layer.div, null, "layer.div is null after destroy" );
95 t.eq( layer.map, null, "layer.map is null after destroy" );
96 t.eq( layer.options, null, "layer.options is null after destroy" );
97 t.eq( layer.multimap, null, "layer.gmap is null after destroy" );