1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>OpenLayers MapGuide Layer Example</title>
4 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5 <link rel="stylesheet" href="style.css" type="text/css" />
6 <style type="text/css">
10 border: 1px solid black;
16 border: 1px solid black;
20 <script src="../lib/OpenLayers.js"></script>
21 <script type="text/javascript">
24 var url = "http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&";
25 //you can use this URL when MapGuide OS is installed locally
26 //var url = "/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&";
28 //Adjust the scale assumptions for MapGuide layers
29 //Tiled layers MUST use a DPI value of 96, untiled layers can use a
30 //different DPI value which will be passed to the server as a parameter.
31 //Tiled and untiled layers must adjust the OL INCHES_PER_UNIT values
32 //for any degree-based projections.
33 var metersPerUnit = 111319.4908; //value returned from mapguide
34 var inPerUnit = OpenLayers.INCHES_PER_UNIT.m * metersPerUnit;
35 OpenLayers.INCHES_PER_UNIT["dd"] = inPerUnit;
36 OpenLayers.INCHES_PER_UNIT["degrees"] = inPerUnit;
37 OpenLayers.DOTS_PER_INCH = 96;
42 var extent = new OpenLayers.Bounds(-87.764987,43.691398,-87.695522,43.797520);
43 var tempScales = [100000,51794.74679,26826.95795,13894.95494,7196.85673,3727.59372,1930.69773,1000];
48 map = new OpenLayers.Map( 'map', mapOptions );
51 mapdefinition: 'Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition',
52 basemaplayergroupname: "Base Layer Group"
57 var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS tiled layer", url, params, options );
61 The following example shows how to access an MG tile cache directly
62 through HTTP bypassing the MG mapagent. This depends on having a
63 pre-populated tile cache
66 options.useHttpTile = true;
67 var cacheUrl = "http://localhost:8008/sheboygan";
68 var httpLayer = new OpenLayers.Layer.MapGuide( "MapGuide HTTP cache tiled layer", cacheUrl, params, options );
69 map.addLayer(httpLayer);
72 map.zoomToMaxExtent();
76 function initUntiled() {
78 var extent = new OpenLayers.Bounds(-87.865114442365922,43.665065564837931,-87.595394059497067,43.823852564430069);
83 map = new OpenLayers.Map( 'map2', mapOptions );
89 useAsyncOverlay: false,
94 mapdefinition: 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition'
97 The MapGuide layer can also be created using mapname and session as follows provided there
98 is some wrapper code to obtain a valid session id and mapname */
101 mapname: 'Sheboygan49ad9e20e7171',
102 session: '7405c17a-0000-1000-8000-0017a4e6ff5d_en_7F0000010AFC0AFB0AFA'
106 var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS untiled baselayer", url, params, options );
109 //this is how to set up the layer for transparent overlays. Requires a valid session ID
110 //and mapName stored in that session.
115 useAsyncOverlay: false,
120 mapName: 'Sheboygan49aeaa04487af',
121 session: '208fd92c-0000-1000-8000-0017a4e6ff5d_en_7F0000010AFC0AFB0AFA',
122 selectioncolor: '0xFF000000',
125 layer = new OpenLayers.Layer.MapGuide( "MapGuide OS Overlay layer", url, params, options );
128 map.addControl(new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')}));
129 map.zoomToMaxExtent();
133 <body onload="initUntiled(); initTiled()">
134 <h1 id="title">MapGuide Layer Example</h1>
140 Demonstrates how to create MapGuide tiled and untiled layers.
143 <p>If prompted for a password, username is Anonymous and an empty password</p>
145 <div id="map" class="smallmap"></div>
147 <div id="layerswitcher"></div>