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-28 12:09:23 -0800 (Fri, 28 Jan 2011) $'
13
  * '$Revision: 5856 $'
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
        var map;
54
        
55
		function round(number,decplaces) {
56
		  var multiplier = '1';
57
		  for (i=0; i < decplaces; i++ ) {
58
		    multiplier = multiplier + '0';
59
		  }
60
		  var rounded = Math.round(number * parseFloat(multiplier)) / parseFloat(multiplier);
61
		  return rounded;
62
		
63
		}
64

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

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

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

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

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

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

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

    
167
        }
168
        
169
        // for named location navigation
170
        function zoomToLocation(locations) {
171
			var selectedLocation = locations.options[locations.selectedIndex].value;
172
			// add a comma for the rectangle
173
			selectedLocation = selectedLocation.replace(" ", ",")
174
			var bounds = OpenLayers.Bounds.fromString(selectedLocation);
175
            map.zoomToExtent(bounds);
176
        }
177
        // -->
178
    </script>
179
  </head>
180
  <body onload="init()">
181
    <!-- <a style="float:right" href="" id="permalink">Permalink</a> -->
182
    <div id="map"></div>
183
	<div id="featureList">
184
		<form>
185
			<select id="locations" onchange="zoomToLocation(this)">
186
				<%@ include file="locations.jsp"%>
187
			</select>
188
		</form>
189
	</div>
190
  </body>
191
</html>
(2-2/2)