Project

General

Profile

1
<%@ page language="java" %>
2
<!--
3
/**
4
  *  '$RCSfile$'
5
  *      Authors:     Matthew Perry
6
  *      Copyright:   2005 University of New Mexico and
7
  *                   Regents of the University of California and the
8
  *                   National Center for Ecological Analysis and Synthesis
9
  *      For Details: http://www.nceas.ucsb.edu/
10
  *
11
  *   '$Author: leinfelder $'
12
  *     '$Date: 2011-01-25 17:02:34 -0800 (Tue, 25 Jan 2011) $'
13
  * '$Revision: 5845 $'
14
  * 
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  *
29
  */
30
-->
31
<%@ include file="../common-settings.jsp"%>
32
<%@ include file="../configure-check.jsp"%>
33
<%
34
	String GEOSERVER_URL = SERVER_URL + "/geoserver";
35
%>
36
<!-- *********************** START Map ************************* -->
37
<html xmlns="http://www.w3.org/1999/xhtml">
38
  <head>
39
    <style type="text/css">
40
        body { background-color:white; }
41
        #map {
42
            width: 760px;
43
            height: 380px;
44
            border: 1px solid #cccccc;
45
        }
46
    </style>
47
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
48
    <script type="text/javascript">
49
        <!--
50

    
51
        // for turning on and off the spatial search control
52
		var control;
53
        
54
		function round(number,decplaces) {
55
		  var multiplier = '1';
56
		  for (i=0; i < decplaces; i++ ) {
57
		    multiplier = multiplier + '0';
58
		  }
59
		  var rounded = Math.round(number * parseFloat(multiplier)) / parseFloat(multiplier);
60
		  return rounded;
61
		
62
		}
63

    
64
        function init(){
65
            var bounds = new OpenLayers.Bounds(-180,-90,180,90);
66
            var map = new OpenLayers.Map('map', { 'maxExtent':bounds, 'maxResolution':'auto'});
67
            //var map = new OpenLayers.Map('map', { controls: [] });
68

    
69
            var metacat_points = new OpenLayers.Layer.WMS( "Metacat Doc Points",
70
                "<%=GEOSERVER_URL%>/wms",
71
                {layers: "data_points",
72
                 transparent: "true", format: "image/gif"} );
73

    
74
            var metacat_bounds = new OpenLayers.Layer.WMS( "Metacat Doc Bounds",
75
                "<%=GEOSERVER_URL%>/wms",
76
                {layers: "data_bounds",
77
                 transparent: "true", format: "image/gif"} );
78

    
79
            var world_borders = new OpenLayers.Layer.WMS( "World Borders",
80
                "<%=GEOSERVER_URL%>/wms",
81
                {layers: "world_borders",
82
                 format: "image/jpeg"} );
83

    
84
            var sanparks_boundaries = new OpenLayers.Layer.WMS( "SANParks Boundaries",
85
                    "<%=GEOSERVER_URL%>/wms",
86
                    {layers: "SANParks_Boundaries_gcs_wgs84",
87
                     transparent: "true", format: "image/gif"} );
88

    
89
            /* 
90
             *   Other possible WMS base layers to include
91
             */
92
			var showAll = true; 
93
			if (showAll) {
94
	            var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
95
	                "http://labs.metacarta.com/wms/vmap0",
96
	                {layers: 'basic'} );
97
	
98
	            var jpl_wms = new OpenLayers.Layer.WMS( "NASA Landsat Mosaic",
99
	                "http://wms.jpl.nasa.gov/wms.cgi", 
100
	                {layers: "modis,global_mosaic"});
101
	
102
	            var demis = new OpenLayers.Layer.WMS( "Demis World Map",
103
	                "http://www2.demis.nl/WMS/wms.asp?wms=WorldMap",
104
	                {layers: 'Bathymetry,Countries,Topography,Hillshading,Coastlines,Waterbodies,Inundated,Rivers,Streams,Builtup+areas,Railroads,Highways,Roads,Trails,Borders,Cities,Settlements,Airports'} );
105
	
106
	            jpl_wms.setVisibility(false);
107
	            ol_wms.setVisibility(false);
108
	            demis.setVisibility(false);
109

    
110
            	map.addLayers([world_borders, sanparks_boundaries, jpl_wms, ol_wms, demis, metacat_points, metacat_bounds]);
111
			}
112
			else {
113
	            map.addLayers([world_borders, sanparks_boundaries, metacat_points, metacat_bounds]);
114
			}
115
            //map.addControl(new OpenLayers.Control.PanZoomBar());
116
            map.addControl(new OpenLayers.Control.MouseToolbar());
117
            map.addControl(new OpenLayers.Control.LayerSwitcher());
118
            map.addControl(new OpenLayers.Control.MousePosition());
119
            //map.addControl(new OpenLayers.Control.Permalink());
120
            //map.addControl(new OpenLayers.Control.Permalink($('permalink')));
121
            // get the drag box event
122
			control = new OpenLayers.Control();
123
			OpenLayers.Util.extend(
124
					control, {
125
					    draw: function () {
126
					        // this Handler.Box will intercept the shift-mousedown
127
					        // before Control.MouseDefault gets to see it
128
					        this.box = new OpenLayers.Handler.Box( control,
129
					            {"done": this.notice}
130
				            	//,{keyMask: OpenLayers.Handler.MOD_SPACE}
131
			            	);
132
					        this.box.activate();
133
					    },
134
					    notice: function (bounds) {
135
					    	var min_px;
136
					        var max_px;
137
					        // check that it is a rectangle
138
					        if (bounds.left) { 
139
						        min_px = new OpenLayers.Pixel( bounds.left, bounds.bottom);
140
						        max_px = new OpenLayers.Pixel( bounds.right, bounds.top);
141
							} else {
142
								var tolerance = new OpenLayers.Pixel(3, 3);
143
							    min_px = new OpenLayers.Pixel( bounds.x - tolerance.x, bounds.y + tolerance.y);
144
							    max_px = new OpenLayers.Pixel( bounds.x + tolerance.x, bounds.y - tolerance.y);
145
							}
146
					        var min_ll = map.getLonLatFromPixel(min_px);
147
					        var max_ll = map.getLonLatFromPixel(max_px);
148
					      	//alert("longitude: " + round(mid_ll.lon,3) + " , latitude: " + round(mid_ll.lat,3) );
149
						    url = '<%=SERVLET_URL%>?action=spatial_query&xmin='+min_ll.lon+'&ymin='+min_ll.lat+'&xmax='+max_ll.lon+'&ymax='+max_ll.lat+'&skin=default';
150
						    OpenLayers.ProxyHost = '';
151
						    newwindow = 
152
							    window.open(
153
									    url,
154
									    'queryWin',
155
						                'height=600,width=800,status=yes,toolbar=yes,menubar=no,location=yes,resizable=yes,scrollbars=yes');
156
						
157
					    }
158
			});
159
			map.addControl(control);
160
			
161
			// zoom to center
162
            if (!map.getCenter()) {
163
                 map.zoomToMaxExtent();
164
            }
165

    
166
        }
167
        // -->
168
    </script>
169
  </head>
170
  <body onload="init()">
171
    <!-- <a style="float:right" href="" id="permalink">Permalink</a> -->
172
    <div id="map"></div>
173
  </body>
174
</html>
    (1-1/1)