3 <script type="text/javascript">var oldAlert = window.alert, gMess; window.alert = function(message) {gMess = message; return true;};</script>
4 <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
5 <script type="text/javascript">window.alert = oldAlert;</script>
6 <script src="../../lib/OpenLayers.js"></script>
7 <script type="text/javascript">
8 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
11 var name = 'MapGuide Test Layer';
12 var url = "http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&";
14 mapdefinition: 'Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition',
15 basemaplayergroupname: "Base Layer Group"
18 mapdefinition: 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition'
21 function test_Layer_MapGuide_untiled_constructor (t) {
24 var trans_format = "image/png";
25 var options = {singleTile:true};
26 if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; }
28 layer = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
29 t.ok( layer instanceof OpenLayers.Layer.MapGuide, "new OpenLayers.Layer.MapGuide returns object" );
30 t.eq( layer.url, "http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&", "layer.url is correct (HTTPRequest inited)" );
31 t.eq( layer.params.mapdefinition, "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition", "params passed in correctly" );
33 t.eq( layer.params.operation, "GETMAPIMAGE", "default params set correctly and copied");
35 t.eq(layer.isBaseLayer, true, "no transparency setting, layer is baselayer");
37 options.transparent = "true";
38 var layer2 = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
39 t.eq(layer2.isBaseLayer, false, "transparency == 'true', layer is not baselayer");
41 options.transparent = true;
42 var layer5 = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
43 t.eq(layer5.isBaseLayer, false, "transparency == true, layer is not baselayer");
45 options.transparent = false;
46 var layer6 = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
47 t.eq(layer6.isBaseLayer, true, "transparency == false, layer is baselayer");
50 function test_Layer_MapGuide_tiled_constructor (t) {
53 var trans_format = "image/png";
54 var options = {singleTile:false};
55 if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; }
57 layer = new OpenLayers.Layer.MapGuide(name, url, paramsTiled, options);
58 t.ok( layer instanceof OpenLayers.Layer.MapGuide, "new OpenLayers.Layer.MapGuide returns object" );
59 t.eq( layer.url, "http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&", "layer.url is correct (HTTPRequest inited)" );
60 t.eq( layer.params.basemaplayergroupname, "Base Layer Group", "params passed in correctly" );
62 t.eq( layer.params.operation, "GETTILEIMAGE", "default params correctly uppercased and copied");
63 t.eq( layer.params.version, "1.2.0", "version params set correctly set");
66 function test_Layer_MapGuide_inittiles (t) {
68 var map = new OpenLayers.Map('map');
69 layer = new OpenLayers.Layer.MapGuide(name, url, paramsTiled);
71 map.setCenter(new OpenLayers.LonLat(0,400000),5);
72 t.eq( layer.grid.length, 6, "Grid rows is correct." );
73 // t.eq( layer.grid[0].length, 6, "Grid cols is correct." );
78 function test_Layer_MapGuide_clone (t) {
81 var options = {tileSize: new OpenLayers.Size(500,50)};
82 var map = new OpenLayers.Map('map', options);
83 layer = new OpenLayers.Layer.MapGuide(name, url, paramsTiled);
86 layer.grid = [ [6, 7],
89 var clone = layer.clone();
91 t.eq( layer.tileSize.w, 300, "layer.tileSize fixed to 300x300");
92 t.ok( clone.grid != layer.grid, "clone does not copy grid");
94 t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
96 layer.tileSize.w += 40;
98 t.eq( clone.alpha, layer.alpha, "alpha copied correctly");
104 function test_Layer_MapGuide_isBaseLayer(t) {
107 var options = {singleTile:true};
108 layer = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
109 t.ok( layer.isBaseLayer, "baselayer is true by default");
111 var newParams = OpenLayers.Util.extend({}, paramsUntiled);
112 options.transparent = "true";
113 layer = new OpenLayers.Layer.MapGuide(name, url, newParams, options);
114 t.ok( !layer.isBaseLayer, "baselayer is false when transparent is set to true");
116 newParams = OpenLayers.Util.extend({}, paramsUntiled);
117 options.isBaseLayer = false;
118 layer = new OpenLayers.Layer.MapGuide(name, url, newParams, options);
119 t.ok( !layer.isBaseLayer, "baselayer is false when option is set to false" );
122 function test_Layer_MapGuide_mergeNewParams (t) {
125 var options = {singleTile:true};
126 var map = new OpenLayers.Map("map");
127 layer = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
129 var newParams = { mapDefinition: 'Library://Samples/Gmap/Maps/gmap.MapDefinition',
130 chickpeas: 'image/png'};
133 map.zoomToMaxExtent();
135 layer.redraw = function() {
136 t.ok(true, "layer is redrawn after new params merged");
139 layer.mergeNewParams(newParams);
141 t.eq( layer.params.mapDefinition, "Library://Samples/Gmap/Maps/gmap.MapDefinition", "mergeNewParams() overwrites well");
142 t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well");
144 newParams.chickpeas = 151;
146 t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hashtable");
150 function test_Layer_MapGuide_destroy (t) {
154 var options = {singleTile:true};
155 var map = new OpenLayers.Map('map');
156 layer = new OpenLayers.Layer.MapGuide(name, url, paramsUntiled, options);
159 map.setCenter(new OpenLayers.LonLat(0,0), 5);
161 //grab a reference to one of the tiles
162 var tile = layer.grid[0][0];
166 // checks to make sure superclass (grid) destroy() was called
168 t.ok( layer.grid == null, "grid set to null");
175 <div id="map" style="width:500px;height:550px"></div>