Project

General

Profile

metacat / lib / style / common / spatial_templates / openlayers1 / map.html @ 3085

1
<html xmlns="http://www.w3.org/1999/xhtml">
2
  <head>
3
    <style type="text/css">
4
        body { background-color:white; }
5
        #map {
6
            width: 760px;
7
            height: 380px;
8
            border: 1px solid #cccccc;
9
        }
10
    </style>
11
    <!-- <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> -->
12

    
13
    <!-- <script src="../../../../spatial/openlayers/lib/OpenLayers.js"></script> -->
14
    <script src="http://openlayers.org/api/2.1/OpenLayers.js"></script>
15
    <script type="text/javascript">
16
        <!--
17
function round(number,decplaces) {
18
  var multiplier = '1';
19
  for (i=0; i < decplaces; i++ ) {
20
    multiplier = multiplier + '0';
21
  }
22
  var rounded = Math.round(number * parseFloat(multiplier)) / parseFloat(multiplier);
23
  return rounded;
24

25
}
26

27
        function init(){
28
            var bounds = new OpenLayers.Bounds(-180,-90,180,90);
29
            var map = new OpenLayers.Map('map', { controls: [], 'maxExtent':bounds, 'maxResolution':'auto'});
30
            //var map = new OpenLayers.Map('map', { controls: [] });
31

32
            var metacat_points = new OpenLayers.Layer.WMS( "Metacat Doc Points",
33
                "../../../../wms",
34
                {layers: "data_points",
35
                 transparent: "true", format: "image/gif"} );
36

37
            var metacat_bounds = new OpenLayers.Layer.WMS( "Metacat Doc Bounds",
38
                "../../../../wms",
39
                {layers: "data_bounds",
40
                 transparent: "true", format: "image/gif"} );
41

42
            var world_borders = new OpenLayers.Layer.WMS( "World Borders",
43
                "../../../../wms",
44
                {layers: "world_borders",
45
                 format: "image/jpeg"} );
46

47
            /* 
48
             *   Other possible WMS base layers to include
49
             */
50

51
            var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
52
                "http://labs.metacarta.com/wms/vmap0",
53
                {layers: 'basic'} );
54

55
            var jpl_wms = new OpenLayers.Layer.WMS( "NASA Landsat Mosaic",
56
                "http://wms.jpl.nasa.gov/wms.cgi", 
57
                {layers: "modis,global_mosaic"});
58

59
            var demis = new OpenLayers.Layer.WMS( "Demis World Map",
60
                "http://www2.demis.nl/WMS/wms.asp?wms=WorldMap",
61
                {layers: 'Bathymetry,Countries,Topography,Hillshading,Coastlines,Waterbodies,Inundated,Rivers,Streams,Builtup+areas,Railroads,Highways,Roads,Trails,Borders,Cities,Settlements,Airports'} );
62

63
            jpl_wms.setVisibility(false);
64
            ol_wms.setVisibility(false);
65
            demis.setVisibility(false);
66

67

68
            map.addLayers([world_borders,jpl_wms, ol_wms, demis, metacat_points, metacat_bounds]);
69
            map.addControl(new OpenLayers.Control.PanZoomBar());
70
            //map.addControl(new OpenLayers.Control.MouseToolbar());
71
            map.addControl(new OpenLayers.Control.LayerSwitcher());
72
            //map.addControl(new OpenLayers.Control.Permalink());
73
            //map.addControl(new OpenLayers.Control.Permalink($('permalink')));
74
            if (!map.getCenter()) map.zoomToMaxExtent();
75

76
map.events.register('click', map, function (e) {
77
    var tolerance = new OpenLayers.Pixel(3, 3);
78
    var min_px = new OpenLayers.Pixel( e.xy.x - tolerance.x, e.xy.y + tolerance.y);
79
    var max_px = new OpenLayers.Pixel( e.xy.x + tolerance.x, e.xy.y - tolerance.y);
80
    var mid_px = new OpenLayers.Pixel( e.xy.x , e.xy.y );
81
    var min_ll = map.getLonLatFromPixel(min_px);
82
    var max_ll = map.getLonLatFromPixel(max_px);
83
    var mid_ll = map.getLonLatFromPixel(mid_px);
84
    //alert("longitude:&nbsp; " + round(mid_ll.lon,3) + " , latitude:&nbsp; " + round(mid_ll.lat,3) );
85
    url = '../../../../metacat?action=spatial_query&xmin='+min_ll.lon+'&ymin='+min_ll.lat+'&xmax='+max_ll.lon+'&ymax='+max_ll.lat+'&skin=default';
86
    OpenLayers.ProxyHost = '';
87
    newwindow = window.open(url,'queryWin',
88
                  'height=600,width=800,status=yes,toolbar=yes,menubar=no,location=yes,resizable=yes,scrollbars=yes');
89

90
});
91

92
        }
93
        // -->
94
    </script>
95
  </head>
96
  <body onload="init()">
97
    <!-- <a style="float:right" href="" id="permalink">Permalink</a> -->
98
    <div id="map"></div>
99
  </body>
100
</html>