]> dev.renevier.net Git - syp.git/blob - openlayers/examples/mvs.html
reset openlayers directory to its original state at the end of build.sh
[syp.git] / openlayers / examples / mvs.html
1 <html>
2 <!-- 
3      This probably needs to be renamed index.html for deployment.
4      Specifically, it needs to be the default page for whatever
5      directory it is in.
6 -->
7 <head>
8
9     <!-- this gmaps key generated for http://openlayers.org/dev/ -->
10     <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
11     <!-- Localhost key -->
12      <!--<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
13 <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
14
15 <script>
16
17 function runMVS() {
18     OpenLayers.ProxyHost = '/proxy/?url='; 
19     if (document.location.protocol != "file:") {
20         theArgs = OpenLayers.Util.getArgs();
21     } else {
22         theArgs = {};
23         theArgs.center = "0,0";
24         theArgs.zoom = "0";            
25         theArgs.data = "textfile.txt";
26         theArgs.controls = 'panzoom,mouse';
27         theArgs.layers = 'openlayers';
28     }
29
30
31     // ----
32     // TODO: Handle all this parsing better.
33     var safeArgs = {}
34
35     var DEFAULT_LAT = 0;
36     var DEFAULT_LON = 0;
37     var DEFAULT_ZOOM_LEVEL = 0;
38     var DEFAULT_CONTROLS = ['panzoom','mouse'];
39     var DEFAULT_LAYERS = ['openlayers'];
40     
41     var IDX_LAT = 0;
42     var IDX_LON = 1;
43
44     safeArgs.centerLat = theArgs.center ? 
45         parseFloat(theArgs.center.split(",")[IDX_LAT]) : DEFAULT_LAT;
46     
47     safeArgs.centerLon = theArgs.center ? 
48         parseFloat(theArgs.center.split(",")[IDX_LON]) : DEFAULT_LON;
49
50     safeArgs.zoom = theArgs.zoom ? parseInt(theArgs.zoom) : DEFAULT_ZOOM_LEVEL;
51     
52     safeArgs.controls = theArgs.controls ? 
53         theArgs.controls.split(",") : DEFAULT_CONTROLS;
54     
55     safeArgs.layers = theArgs.layers ? 
56         theArgs.layers.split(",") : DEFAULT_LAYERS;
57     
58     safeArgs.data = theArgs.data; // TODO: Make this "safe".
59     safeArgs.marker = theArgs.marker; // TODO: Make this "safe".
60     
61     // -----
62     var theMVS = new OpenLayers.Map('map', {controls: [], maxResolution: 'auto'});
63     for(var i = 0; i < safeArgs.controls.length; i++) {
64         switch(safeArgs.controls[i]) {
65             case 'panzoombar':
66                 theMVS.addControl(new OpenLayers.Control.PanZoomBar());
67                 break;
68             case 'panzoom':
69                 theMVS.addControl(new OpenLayers.Control.PanZoom());
70                 break;
71             case 'layerswitcher':
72                 theMVS.addControl(new OpenLayers.Control.LayerSwitcher());
73                 break;
74             case 'mouse':
75                 theMVS.addControl(new OpenLayers.Control.MouseDefaults());
76                 break;
77         }
78     }
79     for(var i = 0; i < safeArgs.layers.length; i++) {
80         switch(safeArgs.layers[i]) {
81             case 'openlayers':
82                 theMVS.addLayer(
83                   new OpenLayers.Layer.WMS( "OpenLayers WMS", 
84                         "http://labs.metacarta.com/wms/vmap0", 
85                         {layers: 'basic'} )
86                   );
87                 break;
88             case 'nasa': 
89                 theMVS.addLayer(
90                     new OpenLayers.Layer.WMS("NASA Mosaic", 
91                        "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
92                        {"EXCEPTIONS" : "application/vnd.ogc.se_inimage",
93                         "format" : "image/jpeg",
94                         layers:"landsat7"}
95                        ));
96                 break;
97             case 'gmaps':
98                 theMVS.addLayer(
99                     new OpenLayers.Layer.Google( "Google" , {type: G_HYBRID_MAP })
100                 );
101                 break;
102         }
103     }
104     theMVS.setCenter(new OpenLayers.LonLat(safeArgs.centerLon, safeArgs.centerLat), safeArgs.zoom);
105
106     if (safeArgs.marker) {
107         var m = new OpenLayers.Layer.Markers("Marker");
108         m.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(safeArgs.centerLon, safeArgs.centerLat)));
109         theMVS.addLayer(m);
110     }
111     if (safeArgs.data) {
112         theMVS.addLayer(new OpenLayers.Layer.Text("Data", {location: safeArgs.data}));
113     }
114
115 }
116 </script>
117 </head>
118 <body style="margin:0px;"
119       onload="runMVS();">
120 <div id="map"
121      style="width: 100%; height: 100%;
122             background: lightyellow;
123            "></div>
124 </body>
125 </html>