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-21 15:08:31 -0800 (Fri, 21 Jan 2011) $'
13
  * '$Revision: 5829 $'
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
function round(number,decplaces) {
51
  var multiplier = '1';
52
  for (i=0; i < decplaces; i++ ) {
53
    multiplier = multiplier + '0';
54
  }
55
  var rounded = Math.round(number * parseFloat(multiplier)) / parseFloat(multiplier);
56
  return rounded;
57

    
58
}
59

    
60
        function init(){
61
            var bounds = new OpenLayers.Bounds(-180,-90,180,90);
62
            var map = new OpenLayers.Map('map', { 'maxExtent':bounds, 'maxResolution':'auto'});
63
            //var map = new OpenLayers.Map('map', { controls: [] });
64

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

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

    
75
            var world_borders = new OpenLayers.Layer.WMS( "World Borders",
76
                "<%=GEOSERVER_URL%>/wms",
77
                {layers: "world_borders",
78
                 format: "image/jpeg"} );
79

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

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

    
106
            	map.addLayers([world_borders, sanparks_boundaries, jpl_wms, ol_wms, demis, metacat_points, metacat_bounds]);
107
			}
108
			else {
109
	            map.addLayers([world_borders, sanparks_boundaries, metacat_points, metacat_bounds]);
110
			}
111
            //map.addControl(new OpenLayers.Control.PanZoomBar());
112
            map.addControl(new OpenLayers.Control.MouseToolbar());
113
            map.addControl(new OpenLayers.Control.LayerSwitcher());
114
            //map.addControl(new OpenLayers.Control.Permalink());
115
            //map.addControl(new OpenLayers.Control.Permalink($('permalink')));
116
            if (!map.getCenter()) map.zoomToMaxExtent();
117

    
118
map.events.register('click', map, function (e) {
119
    var tolerance = new OpenLayers.Pixel(3, 3);
120
    var min_px = new OpenLayers.Pixel( e.xy.x - tolerance.x, e.xy.y + tolerance.y);
121
    var max_px = new OpenLayers.Pixel( e.xy.x + tolerance.x, e.xy.y - tolerance.y);
122
    var mid_px = new OpenLayers.Pixel( e.xy.x , e.xy.y );
123
    var min_ll = map.getLonLatFromPixel(min_px);
124
    var max_ll = map.getLonLatFromPixel(max_px);
125
    var mid_ll = map.getLonLatFromPixel(mid_px);
126
    //alert("longitude:&nbsp; " + round(mid_ll.lon,3) + " , latitude:&nbsp; " + round(mid_ll.lat,3) );
127
    url = '<%=SERVLET_URL%>?action=spatial_query&xmin='+min_ll.lon+'&ymin='+min_ll.lat+'&xmax='+max_ll.lon+'&ymax='+max_ll.lat+'&skin=default';
128
    OpenLayers.ProxyHost = '';
129
    newwindow = window.open(url,'queryWin',
130
                  'height=600,width=800,status=yes,toolbar=yes,menubar=no,location=yes,resizable=yes,scrollbars=yes');
131

    
132
});
133

    
134
        }
135
        // -->
136
    </script>
137
  </head>
138
  <body onload="init()">
139
    <!-- <a style="float:right" href="" id="permalink">Permalink</a> -->
140
    <div id="map"></div>
141
  </body>
142
</html>
    (1-1/1)