Ticket #995: mapguide.3.patch
| File mapguide.3.patch, 29.2 kB (added by crschmidt, 1 year ago) |
|---|
-
tests/Layer/test_MapGuide.html
old new 1 <html> 2 <head> 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); 9 var layer; 10 11 var name = 'MapGuide Test Layer'; 12 var url = "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi"; 13 var paramsTiled = { 14 mapDefinition: 'Library://Samples/Gmap/Maps/gmapTiled.MapDefinition', 15 groupName: "BaseLayerGroup", 16 singleTile: false 17 } 18 var paramsUntiled = { 19 mapDefinition: 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition', 20 singleTile: true 21 }; 22 23 function test_01_Layer_MapGuide_untiled_constructor (t) { 24 t.plan( 8 ); 25 26 var trans_format = "image/png"; 27 if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; } 28 29 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 30 t.ok( layer instanceof OpenLayers.Layer.MapGuide, "new OpenLayers.Layer.MapGuide returns object" ); 31 t.eq( layer.url, "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi", "layer.url is correct (HTTPRequest inited)" ); 32 t.eq( layer.params.mapDefinition, "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition", "params passed in correctly" ); 33 34 t.eq( layer.params.operation, "GETMAPIMAGE", "default params set correctly and copied"); 35 36 t.eq(layer.isBaseLayer, true, "no transparency setting, layer is baselayer"); 37 38 paramsUntiled.transparent = "true"; 39 var layer2 = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 40 t.eq(layer2.isBaseLayer, false, "transparency == 'true', wms is not baselayer"); 41 42 paramsUntiled.transparent = true; 43 var layer5 = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 44 t.eq(layer5.isBaseLayer, false, "transparency == true, wms is not baselayer"); 45 46 paramsUntiled.transparent = false; 47 var layer6 = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 48 t.eq(layer6.isBaseLayer, true, "transparency == false, wms is baselayer"); 49 } 50 51 function test_02_Layer_MapGuide_tiled_constructor (t) { 52 t.plan( 6 ); 53 54 var trans_format = "image/png"; 55 if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; } 56 57 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsTiled); 58 t.ok( layer instanceof OpenLayers.Layer.MapGuide, "new OpenLayers.Layer.MapGuide returns object" ); 59 t.eq( layer.url, "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi", "layer.url is correct (HTTPRequest inited)" ); 60 t.eq( layer.params.basemaplayergroupname, "BaseLayerGroup", "params passed in correctly" ); 61 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"); 64 t.eq( layer.gridOrigin, "upperLeft", "grid origin set correctly set"); 65 } 66 /* 67 function test_Layer_MapGuide_bboxEncoding (t) { 68 t.plan( 6 ); 69 70 var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 71 layer = new OpenLayers.Layer.MapGuide(name, url, params, {encodeBBOX:true}); 72 var map = new OpenLayers.Map('map'); 73 map.addLayer(layer); 74 var pixel = new OpenLayers.Pixel(5,6); 75 var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); 76 tile.draw(); 77 78 var img = tile.imgDiv; 79 var tParams = OpenLayers.Util.extend({}, 80 OpenLayers.Util.upperCaseObject(params)); 81 tParams = OpenLayers.Util.extend(tParams, { 82 SERVICE: "WMS", VERSION: "1.1.1", 83 REQUEST: "GetMap", STYLES: "", 84 EXCEPTIONS: "application/vnd.ogc.se_inimage", 85 SRS: "EPSG:4326", BBOX: "1,2,3,4", 86 WIDTH: "256", HEIGHT: "256" 87 }); 88 t.eq( img.src, 89 url + "?" + OpenLayers.Util.getParameterString(tParams), 90 "image src is created correctly via addtile" ); 91 t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" ); 92 t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" ); 93 94 var firstChild = layer.div.firstChild.firstChild; 95 if (!isMozilla) 96 t.ok( true, "skipping element test outside of Mozilla"); 97 else 98 t.ok( firstChild instanceof HTMLElement, "div first child is an image object" ); 99 t.eq( firstChild.src, 100 url + "?" + OpenLayers.Util.getParameterString(tParams), 101 "div first child is correct image object" ); 102 t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." ); 103 map.destroy(); 104 } 105 */ 106 107 function test_03_Layer_MapGuide_inittiles (t) { 108 t.plan( 2 ); 109 var map = new OpenLayers.Map('map'); 110 layer = new OpenLayers.Layer.MapGuide(name, url, paramsTiled); 111 map.addLayer(layer); 112 map.setCenter(new OpenLayers.LonLat(0,400000),5); 113 t.eq( layer.grid.length, 6, "Grid rows is correct." ); 114 t.eq( layer.grid[0].length, 6, "Grid cols is correct." ); 115 map.destroy(); 116 } 117 118 119 function test_04_Layer_MapGuide_clone (t) { 120 t.plan(4); 121 122 var options = {tileSize: new OpenLayers.Size(500,50)}; 123 var map = new OpenLayers.Map('map', options); 124 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsTiled); 125 map.addLayer(layer); 126 127 layer.grid = [ [6, 7], 128 [8, 9]]; 129 130 var clone = layer.clone(); 131 132 t.eq( layer.tileSize.w, 300, "layer.tileSize fixed to 300x300"); 133 t.ok( clone.grid != layer.grid, "clone does not copy grid"); 134 135 t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned"); 136 137 layer.tileSize.w += 40; 138 139 t.eq( clone.alpha, layer.alpha, "alpha copied correctly"); 140 141 layer.grid = null; 142 map.destroy(); 143 } 144 145 function test_05_Layer_MapGuide_isBaseLayer(t) { 146 t.plan(3); 147 148 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 149 t.ok( layer.isBaseLayer, "baselayer is true by default"); 150 151 var newParams = OpenLayers.Util.extend({}, paramsUntiled); 152 newParams.transparent = "true"; 153 layer = new OpenLayers.Layer.MapGuide(name, url, {}, newParams); 154 t.ok( !layer.isBaseLayer, "baselayer is false when transparent is set to true"); 155 156 newParams = OpenLayers.Util.extend({}, paramsUntiled); 157 newParams.isBaseLayer = false; 158 layer = new OpenLayers.Layer.MapGuide(name, url, {}, newParams); 159 t.ok( !layer.isBaseLayer, "baselayer is false when option is set to false" ); 160 } 161 162 function test_06_Layer_MapGuide_mergeNewParams (t) { 163 t.plan( 4 ); 164 165 var map = new OpenLayers.Map("map"); 166 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 167 168 var newParams = { mapDefinition: 'Library://Samples/Gmap/Maps/gmap.MapDefinition', 169 chickpeas: 'image/png'}; 170 171 map.addLayer(layer); 172 map.zoomToMaxExtent(); 173 174 layer.redraw = function() { 175 t.ok(true, "layer is redrawn after new params merged"); 176 } 177 178 layer.mergeNewParams(newParams); 179 180 t.eq( layer.params.mapDefinition, "Library://Samples/Gmap/Maps/gmap.MapDefinition", "mergeNewParams() overwrites well"); 181 t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well"); 182 183 newParams.chickpeas = 151; 184 185 t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hashtable"); 186 map.destroy(); 187 } 188 189 /* 190 function test_07_Layer_MapGuide_getFullRequestString (t) { 191 192 193 t.plan( 2 ); 194 var map = new OpenLayers.Map('map'); 195 map.projection = "xx"; 196 tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; 197 tParams = { layers: 'basic', 198 format: 'image/png'}; 199 var tLayer = new OpenLayers.Layer.MapGuide(name, tUrl, tParams); 200 map.addLayer(tLayer); 201 str = tLayer.getFullRequestString(); 202 var tParams = { 203 LAYERS: "basic", FORMAT: "image/png", SERVICE: "WMS", 204 VERSION: "1.1.1", REQUEST: "GetMap", STYLES: "", 205 EXCEPTIONS: "application/vnd.ogc.se_inimage", SRS: "xx" 206 }; 207 t.eq(str, 208 tUrl + "?" + OpenLayers.Util.getParameterString(tParams), 209 "getFullRequestString() adds SRS value"); 210 211 map.removeLayer(tLayer); 212 tLayer.projection = "none"; 213 map.addLayer(tLayer); 214 str = tLayer.getFullRequestString(); 215 delete tParams['SRS']; 216 t.eq(str, 217 tUrl + "?" + OpenLayers.Util.getParameterString(tParams), 218 "getFullRequestString() by default does *not* add SRS value if projection is 'none'"); 219 map.destroy(); 220 221 }*/ 222 223 function test_99_Layer_MapGuide_destroy (t) { 224 225 t.plan( 1 ); 226 227 var map = new OpenLayers.Map('map'); 228 layer = new OpenLayers.Layer.MapGuide(name, url, {}, paramsUntiled); 229 map.addLayer(layer); 230 231 map.setCenter(new OpenLayers.LonLat(0,0), 5); 232 233 //grab a reference to one of the tiles 234 var tile = layer.grid[0][0]; 235 236 layer.destroy(); 237 238 // checks to make sure superclass (grid) destroy() was called 239 240 t.ok( layer.grid == null, "grid set to null"); 241 } 242 243 244 </script> 245 </head> 246 <body> 247 <div id="map" style="width:500px;height:550px"></div> 248 </body> 249 </html> -
tests/list-tests.html
old new 59 59 <li>Layer/test_HTTPRequest.html</li> 60 60 <li>Layer/test_Image.html</li> 61 61 <li>Layer/test_KaMap.html</li> 62 <li>Layer/test_MapGuide.html</li> 62 63 <li>Layer/test_MapServer.html</li> 63 64 <li>Layer/test_Markers.html</li> 64 65 <li>Layer/test_MultiMap.html</li> -
lib/OpenLayers/Layer/Grid.js
old new 58 58 * {Integer} How many tiles are still loading? 59 59 */ 60 60 numLoadingTiles: 0, 61 62 /** 63 * Property: gridOrigin 64 * {String} where to start the 0,0 tile for the grid 65 */ 66 gridOrigin: 'lowerLeft', 61 67 62 68 /** 63 69 * Constructor: OpenLayers.Layer.Grid … … 327 333 var tileoffsetx = -tilecolremain * this.tileSize.w; 328 334 var tileoffsetlon = extent.left + tilecol * tilelon; 329 335 330 var offsetlat = bounds.top - (extent.bottom + tilelat); 331 var tilerow = Math.ceil(offsetlat/tilelat) + this.buffer; 332 var tilerowremain = tilerow - offsetlat/tilelat; 333 var tileoffsety = -tilerowremain * this.tileSize.h; 334 var tileoffsetlat = extent.bottom + tilerow * tilelat; 336 var offsetlat, tilerow, tilerowremain, tileoffsety, tileoffsetlat; 337 if (this.gridOrigin == 'upperLeft') { 338 offsetlat = extent.top - bounds.top + tilelat; 339 tilerow = Math.floor(offsetlat/tilelat) - this.buffer; 340 tilerowremain = tilerow - offsetlat/tilelat; 341 tileoffsety = tilerowremain * this.tileSize.h; 342 tileoffsetlat = extent.top - tilelat*tilerow; 343 } else { //default lower left 344 offsetlat = bounds.top - (extent.bottom + tilelat); 345 tilerow = Math.ceil(offsetlat/tilelat) + this.buffer; 346 tilerowremain = tilerow - offsetlat/tilelat; 347 tileoffsety = -tilerowremain * this.tileSize.h; 348 tileoffsetlat = extent.bottom + tilerow * tilelat; 349 } 335 350 336 351 tileoffsetx = Math.round(tileoffsetx); // heaven help us 337 352 tileoffsety = Math.round(tileoffsety); -
lib/OpenLayers/Layer/MapGuide.js
old new 1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 2 * licence. See http://svn.openlayers.org/trunk/openlayers/license.txt for the 3 * full text of the license. */ 4 5 /** 6 * @requires OpenLayers/Ajax.js 7 * @requires OpenLayers/Layer/Grid.js 8 * 9 * Class: OpenLayers.Layer.MapGuide 10 * Instances of OpenLayers.Layer.MapGuide are used to display 11 * data from a MapGuide OS instance. 12 * 13 * Inherits from: 14 * - <OpenLayers.Layer.Grid> 15 */ 16 OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, { 17 18 /** 19 * APIProperty: isBaseLayer 20 * {Boolean} Treat this layer as a base layer. Default is true. 21 **/ 22 isBaseLayer: true, 23 24 /** 25 * APIProperty: singleTile 26 * {Boolean} use tile server or request single tile image. Note that using 27 * singleTile *and* isBaseLayer false is *not recommend*: it uses synchronous 28 * XMLHttpRequests to load tiles, and this will *lock up users browsers* 29 * during requests. 30 **/ 31 singleTile: false, 32 33 /** 34 * Constant: TILE_PARAMS 35 * {Object} Hashtable of default parameter key/value pairs for tiled layer 36 */ 37 TILE_PARAMS: { 38 operation: 'GETTILEIMAGE', 39 version: '1.2.0' 40 }, 41 42 /** 43 * Constant: SINGLE_TILE_PARAMS 44 * {Object} Hashtable of default parameter key/value pairs for untiled layer 45 */ 46 SINGLE_TILE_PARAMS: { 47 operation: 'GETMAPIMAGE', 48 version: '1.0.0' 49 }, 50 51 /** 52 * Property: session 53 * {String} MapGuide session ID 54 * (for untiled overlays layers only) 55 **/ 56 session: null, 57 58 /** 59 * Property: mapName 60 * {String} Name of the map as stored in the MapGuide session. 61 * (for untiled overlay layers only) 62 **/ 63 mapName: null, 64 65 /** 66 * Property: mapDefinition 67 * {String} The MapGuide resource definition 68 * (e.g. Library://Samples/Gmap/Maps/gmapTiled.MapDefinition) 69 **/ 70 mapDefinition: null, 71 72 /** 73 * Property: groupName 74 * {String} GroupName for tiled MapGuide layers 75 **/ 76 groupName: null, 77 78 /** 79 * Property: format 80 * {String} Image format to be returned (for untiled overlay layers only) 81 **/ 82 format: 'PNG', 83 84 /** 85 * Property: locale 86 * {String} Locale setting 87 * (for untiled overlays layers only) 88 **/ 89 locale: "en", 90 91 /** 92 * Property: defaultSize 93 * {<OpenLayers.Size>} Tile size as produced by MapGuide server 94 **/ 95 defaultSize: new OpenLayers.Size(300,300), 96 97 /** 98 * Constructor: OpenLayers.Layer.MapGuide 99 * Create a new Mapguide layer, either tiled or untiled. 100 * 101 * For tiled layers, the 'groupName' and 'mapDefnition' options 102 * must be specified as options. 103 * 104 * For untiled layers, specify either combination of 'mapName' and 'session', 105 * or 'mapDefinition' and 'locale'. 106 * 107 * Parameters: 108 * name - {String} Name of the layer displayed in the interface 109 * url - {String} Location of the MapGuide mapagent executable 110 * (e.g. http://localhost:8008/mapguide/mapagent/mapagent.fcgi) 111 * params - {Object} hashtable of additional parameters to use. Some 112 * parameters may require additional code on the serer. The ones that you 113 * may want to use are: 114 * - showLayers - {String} A comma separated list of GUID's for the layers to display 115 * eg: 'cvc-xcv34,453-345-345sdf'. 116 * - hideLayers - {String} A comma separated list of GUID's for the layers to hide eg: 117 * 'cvc-xcv34,453-345-345sdf'. 118 * - showGroups - {String} A comma separated list of GUID's for the groups to display 119 * eg: 'cvc-xcv34,453-345-345sdf'. 120 * - hideGroups - {String} A comma separated list of GUID's for the groups to hide 121 * eg: 'cvc-xcv34,453-345-345sdf' 122 * - selectionXml - {String} A selection xml string Some server plumbing is 123 * required to read such a value. 124 * options - {Ojbect} Hashtable of extra options to tag onto the layer; 125 * will vary depending if tiled or untiled maps are being requested 126 */ 127 initialize: function(name, url, params, options) { 128 129 OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments); 130 console.log(params); 131 // unless explicitly set in options, if the layer is transparent, 132 // it will be an overlay 133 if (options == null || options.isBaseLayer == null) { 134 this.isBaseLayer = ((this.transparent != "true") && 135 (this.transparent != true)); 136 } 137 138 //initialize for untiled layers 139 if (this.singleTile) { 140 if (this.session && this.mapName) { 141 this.params.session = this.session; 142 this.params.mapName = this.mapName; 143 } else if (this.mapDefinition) { 144 this.params.mapDefinition = this.mapDefinition; 145 this.params.locale = this.locale; 146 } 147 this.params.format = this.format; 148 149 OpenLayers.Util.applyDefaults( 150 this.params, 151 this.SINGLE_TILE_PARAMS 152 ); 153 } else { 154 //initialize for tiled layers 155 this.params.mapDefinition = this.mapDefinition; 156 this.params.basemaplayergroupname = this.groupName; 157 OpenLayers.Util.applyDefaults( 158 this.params, 159 this.TILE_PARAMS 160 ); 161 this.setTileSize(this.defaultSize); 162 this.gridOrigin = 'upperLeft'; 163 } 164 }, 165 166 /** 167 * Method: clone 168 * Create a clone of this layer 169 * 170 * Returns: 171 * {<OpenLayers.Layer.MapGuide>} An exact clone of this layer 172 */ 173 clone: function (obj) { 174 if (obj == null) { 175 obj = new OpenLayers.Layer.MapGuide(this.name, 176 this.url, 177 this.params, 178 this.options); 179 } 180 //get all additions from superclasses 181 obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]); 182 183 return obj; 184 }, 185 186 /** 187 * Method: addTile 188 * Creates a tile, initializes it, and adds it to the layer div. 189 * 190 * Parameters: 191 * bounds - {<OpenLayers.Bounds>} 192 * 193 * Returns: 194 * {<OpenLayers.Tile.Image>} The added OpenLayers.Tile.Image 195 */ 196 addTile:function(bounds,position) { 197 return new OpenLayers.Tile.Image(this, position, bounds, null, this.tileSize); 198 }, 199 200 /** 201 * Method: getURL 202 * Return a query string for this layer 203 * 204 * Parameters: 205 * bounds - {<OpenLayers.Bounds>} A bounds representing the bbox 206 * for the request 207 * 208 * Returns: 209 * {String} A string with the layer's url and parameters and also 210 * the passed-in bounds and appropriate tile size specified 211 * as parameters. 212 */ 213 getURL: function (bounds) { 214 var url; 215 var center = bounds.getCenterLonLat(); 216 var mapSize = this.map.getCurrentSize(); 217 218 if (this.singleTile) { 219 //set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY 220 var params = {}; 221 params.setdisplaydpi = OpenLayers.DOTS_PER_INCH; 222 params.setdisplayheight = mapSize.h*this.ratio; 223 params.setdisplaywidth = mapSize.w*this.ratio; 224 params.setviewcenterx = center.lon; 225 params.setviewcentery = center.lat; 226 params.setviewscale = this.map.getScale(); 227 228 if (!this.isBaseLayer) { 229 // in this case the main image operation is remapped to this 230 this.params.operation = "GETDYNAMICMAPOVERLAYIMAGE"; 231 232 //but we first need to call GETVISIBLEMAPEXTENT to set the extent 233 var getVisParams = {}; 234 getVisParams.operation = "GETVISIBLEMAPEXTENT"; 235 getVisParams.version = "1.0.0"; 236 getVisParams.session = this.session; 237 getVisParams.mapName = this.mapName; 238 getVisParams.format = 'text/xml'; 239 getVisParams = OpenLayers.Util.extend(getVisParams, params); 240 241 new OpenLayers.Ajax.Request(this.url, 242 { parameters: getVisParams, 243 method: 'get', 244 asynchronous: false //must be synchronous call to return control here 245 }); 246 } 247 248 //construct the full URL 249 url = this.getFullRequestString( params ); 250 } else { 251 252 //tiled version 253 var currentRes = this.map.getResolution(); 254 var colidx = Math.floor((bounds.left-this.maxExtent.left)/currentRes); 255 colidx = Math.round(colidx/this.tileSize.w); 256 var rowidx = Math.floor((this.maxExtent.top-bounds.top)/currentRes); 257 rowidx = Math.round(rowidx/this.tileSize.h); 258 259 url = this.getFullRequestString( 260 { 261 tilecol: colidx, 262 tilerow: rowidx, 263 scaleindex: this.resolutions.length - this.map.zoom - 1 264 }); 265 } 266 267 return url; 268 }, 269 270 /** 271 * Method: getFullRequestString 272 * getFullRequestString on MapGuide layers is special, because we 273 * do a regular expression replace on ',' in parameters to '+'. 274 * This is why it is subclassed here. 275 * 276 * Parameters: 277 * altUrl - {String} Alternative base URL to use. 278 * 279 * Returns: 280 * {String} A string with the layer's url appropriately encoded for MapGuide 281 */ 282 getFullRequestString:function(newParams, altUrl) { 283 // use layer's url unless altUrl passed in 284 var url = (altUrl == null) ? this.url : altUrl; 285 286 // if url is not a string, it should be an array of strings, 287 // in which case we will randomly select one of them in order 288 // to evenly distribute requests to different urls. 289 if (typeof url == "object") { 290 url = url[Math.floor(Math.random()*url.length)]; 291 } 292 // requestString always starts with url 293 var requestString = url; 294 295 // create a new params hashtable with all the layer params and the 296 // new params together. then convert to string 297 var allParams = OpenLayers.Util.extend({}, this.params); 298 allParams = OpenLayers.Util.extend(allParams, newParams); 299 // ignore parameters that are already in the url search string 300 var urlParams = OpenLayers.Util.upperCaseObject( 301 OpenLayers.Util.getArgs(url)); 302 for(var key in allParams) { 303 if(key.toUpperCase() in urlParams) { 304 delete allParams[key]; 305 } 306 } 307 var paramsString = OpenLayers.Util.getParameterString(allParams); 308 309 /* MapGuide needs '+' seperating things like bounds/height/width. 310 Since typically this is URL encoded, we use a slight hack: we 311 depend on the list-like functionality of getParameterString to 312 leave ',' only in the case of list items (since otherwise it is 313 encoded) then do a regular expression replace on the , characters 314 to '+' */ 315 paramsString = paramsString.replace(/,/g, "+"); 316 317 if (paramsString != "") { 318 var lastServerChar = url.charAt(url.length - 1); 319 if ((lastServerChar == "&") || (lastServerChar == "?")) { 320 requestString += paramsString; 321 } else { 322 if (url.indexOf('?') == -1) { 323 //serverPath has no ? -- add one 324 requestString += '?' + paramsString; 325 } else { 326 //serverPath contains ?, so must already have paramsString at the end 327 requestString += '&' + paramsString; 328 } 329 } 330 } 331 return requestString; 332 }, 333 CLASS_NAME: "OpenLayers.Layer.MapGuide" 334 }); -
lib/OpenLayers.js
old new 103 103 "OpenLayers/Layer/Yahoo.js", 104 104 "OpenLayers/Layer/HTTPRequest.js", 105 105 "OpenLayers/Layer/Grid.js", 106 "OpenLayers/Layer/MapGuide.js", 106 107 "OpenLayers/Layer/MapServer.js", 107 108 "OpenLayers/Layer/MapServer/Untiled.js", 108 109 "OpenLayers/Layer/KaMap.js", -
examples/mapguide.html
old new 1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <style type="text/css"> 4 #map { 5 width: 400px; 6 height: 400px; 7 border: 1px solid black; 8 float:left; 9 } 10 #map2 { 11 width: 400px; 12 height: 400px; 13 border: 1px solid black; 14 float:left; 15 } 16 </style> 17 <script src="../lib/OpenLayers.js"></script> 18 <script type="text/javascript"> 19 20 var map, layer; 21 var url = "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi"; 22 //var url = "/mapguide/mapagent/mapagent.fcgi"; 23 24 //tiled version 25 function init(){ 26 27 OpenLayers.DOTS_PER_INCH = 96; 28 var extent = new OpenLayers.Bounds(-3631568.75,-1293815.5,4491139.5833333321,4937122); 29 var tempScales = [50000000,23207944.16806,10772173.45016,5000000,2320794.41681,1077217.34502,500000,232079.44168,107721.7345,50000]; 30 var mapOptions = { 31 maxExtent: extent, 32 scales: tempScales, 33 units: 'm', 34 projection: 'EPSG:42304' 35 }; 36 map = new OpenLayers.Map( 'map', mapOptions ); 37 38 var options = { 39 mapDefinition: 'Library://Samples/Gmap/Maps/gmapTiled.MapDefinition', 40 groupName: "BaseLayerGroup", 41 singleTile: false, 42 } 43 var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS tiled layer", url, {}, options ); 44 map.addLayer(layer); 45 46 map.zoomToMaxExtent(); 47 } 48 49 //un-tiled version 50 function initUntiled() { 51 52 OpenLayers.DOTS_PER_INCH = 96; 53 var extent = new OpenLayers.Bounds(-87.865114442365922,43.665065564837931,-87.595394059497067,43.823852564430069); 54 var mapOptions = { 55 maxExtent: extent, 56 maxResolution: 'auto' 57 }; 58 map = new OpenLayers.Map( 'map2', mapOptions ); 59 60 var options = { 61 mapDefinition: 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition', 62 buffer: 1, 63 singleTile: true 64 }; 65 var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS untiled baselayer", url, {}, options ); 66 map.addLayer(layer); 67 68 //this is how to set up the layer for transparent overlays. Requires a valid session ID 69 //and mapName stored in that session. 70 //If the mapagent URL is on a different server than this OL layer, the OpenLayers proxy script 71 //must be used since this layer must perform an additional AJAX request before requesting the 72 //map image 73 /* 74 var options = { 75 isBaseLayer: false, 76 transparent: true, 77 mapName: 'Sheboygan', 78 session: '0b8cb80e-0000-1000-8003-0017a4e6ff5d_en_C0A802AD0AFC0AFB0AFA', 79 buffer: 1, 80 singleTile: true 81 }; 82 layer = new OpenLayers.Layer.MapGuide( "MapGuide OS Overlay layer", url, {}, options ); 83 //map.addLayer(layer); 84 */ 85 map.zoomToMaxExtent(); 86 } 87 </script> 88 </head> 89 <body onload="initUntiled(); init()"> 90 <p>If prompted for a password, username is Anonymous and an empty password</p> 91 <div id="map"></div> 92 <div id="map2"></div> 93 </body> 94 </html>
