OpenLayers OpenLayers

Ticket #1511: mapguide.html

File mapguide.html, 4.4 kB (added by openlayers, 5 months ago)

modified mapguide example with both tiled and untiled examples

Line 
1 <html xmlns="http://www.w3.org/1999/xhtml">
2   <head>
3     <style type="text/css">
4         #map {
5             width: 600px;
6             height: 600px;
7             border: 1px solid black;
8             float:left;
9         }
10         #map2 {
11             width: 600px;
12             height: 600px;
13             border: 1px solid black;
14             float:left;
15         }
16     </style>
17     <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
18     <script type="text/javascript">
19    
20         var map, map2, layer;
21         var url = "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi";
22         //you can use this URL when MapGuide OS is installed locally
23         var url = "http://127.0.0.1:8018/mapguide/mapagent/mapagent.fcgi";
24        
25         //tiled version
26         function initTiled(){
27        
28             OpenLayers.DOTS_PER_INCH = 96;
29             var extent = new OpenLayers.Bounds(-87.865114442365922,43.665065564837931,-87.595394059497067,43.823852564430069);       
30             var tempScales =[1000,1930.6977300000001,3727.5937199999998,7196.8567300000004,13894.95494,26826.95795,51794.746789999997,100000];
31            
32             var mapOptions = {
33                 maxExtent: extent,
34                 scales: tempScales
35             };
36             map = new OpenLayers.Map( 'map', mapOptions );
37            
38              var params = {
39               mapdefinition: 'Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition',
40               basemaplayergroupname: "Base Layer Group"
41             }
42            
43             var options = {
44               singleTile: false
45             }
46             var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS tiled layer", url, params, options );
47             map.addLayer(layer);
48             map.addControl(new OpenLayers.Control.MousePosition());           
49             map.zoomToMaxExtent();
50         }
51
52         //un-tiled version
53         function initUntiled() {
54        
55           OpenLayers.DOTS_PER_INCH = 96;
56           var extent = new OpenLayers.Bounds(-87.865114442365922,43.665065564837931,-87.595394059497067,43.823852564430069);
57           var mapOptions = {
58                 maxExtent: extent,
59                 maxResolution: 'auto'
60           };
61           map2 = new OpenLayers.Map( 'map2', mapOptions );
62            
63           var options = {
64               buffer: 1,
65               singleTile: true
66           };
67          
68           var params = {
69               mapdefinition: 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition'
70           };
71           /*
72                     The MapGuide layer can also be created using mapname and session as follows provided there
73                     is some wrapper code to obtain a valid session id and mapname
74           var params = {
75               mapname: 'Sheboygan47b3560bf1071',
76               session: '043bb716-0000-1000-8000-0017a4e6ff5d_en_7F0000010AFC0AFB0AFA'
77           };
78           */
79           var layer = new OpenLayers.Layer.MapGuide( "MapGuide OS untiled baselayer", url, params, options );
80           map2.addLayer(layer);
81          
82           //this is how to set up the layer for transparent overlays.  Requires a valid session ID
83           //and mapName stored in that session.
84           //If the mapagent URL is on a different server than this OL layer, the OpenLayers proxy script
85           //must be used since this layer must perform an additional AJAX request before requesting the
86           //map  image
87           /*
88             var options = {
89               isBaseLayer: false,
90               transparent: true,
91               buffer: 1,
92               singleTile: true
93             };
94             var params = {
95               mapName: 'Sheboygan',
96               session: '0b8cb80e-0000-1000-8003-0017a4e6ff5d_en_C0A802AD0AFC0AFB0AFA',
97             };
98             layer = new OpenLayers.Layer.MapGuide( "MapGuide OS Overlay layer", url, params, options );
99             map.addLayer(layer);
100           */
101             map2.addControl(new OpenLayers.Control.MousePosition());       
102           map2.zoomToMaxExtent();
103     }
104    
105
106
107     </script>
108   </head>
109   <body onload="initUntiled(); initTiled()">
110     <p>If prompted for a password, username is Anonymous and an empty password</p>
111    
112     Modified example by Zac Spitzer, first map is tiled, second map is not tiled,<br>
113     note that the mouse position doesn't match between the different versions
114     <div id="map"></div>
115     <div id="map2"></div>
116    
117     <br>
118    
119   </body>
120 </html>