Project

General

Profile

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