1
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
2
|
<head>
|
3
|
<script src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us'></script>
|
4
|
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
5
|
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
|
6
|
|
7
|
<link rel="stylesheet" href="/geoserver/style.css" type="text/css" />
|
8
|
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css" />
|
9
|
|
10
|
<style type="text/css">
|
11
|
body {
|
12
|
margin: 1em;
|
13
|
}
|
14
|
#map {
|
15
|
width: 95%;
|
16
|
height: 512px;
|
17
|
border: 1px solid gray;
|
18
|
}
|
19
|
div.olControlMousePosition {
|
20
|
color: white;
|
21
|
}
|
22
|
#bounds {
|
23
|
font-size: 0.9em;
|
24
|
}
|
25
|
</style>
|
26
|
|
27
|
<script src="http://openlayers.org/api/OpenLayers.js"></script>
|
28
|
<script type="text/javascript">
|
29
|
|
30
|
// make map available for easy debugging
|
31
|
var map;
|
32
|
|
33
|
// avoid pink tiles
|
34
|
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
|
35
|
OpenLayers.Util.onImageLoadErrorColor = "transparent";
|
36
|
|
37
|
function init(){
|
38
|
|
39
|
/**
|
40
|
* The commercial layers (Google, Virtual Earth, and Yahoo) are
|
41
|
* in a custom projection - we're calling this Spherical Mercator.
|
42
|
* GeoServer understands that requests for EPSG:900913 should
|
43
|
* match the projection for these commercial layers. Note that
|
44
|
* this is not a standard EPSG code - so, if you want to load
|
45
|
* layers from another WMS, it will have to be configured to work
|
46
|
* with this projection.
|
47
|
*/
|
48
|
var options = {
|
49
|
// the "community" epsg code for spherical mercator
|
50
|
projection: "EPSG:900913",
|
51
|
// map horizontal units are meters
|
52
|
units: "m",
|
53
|
// this resolution displays the globe in one 256x256 pixel tile
|
54
|
maxResolution: 78271.51695,
|
55
|
// these are the bounds of the globe in sperical mercator
|
56
|
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
|
57
|
20037508, 20037508)
|
58
|
};
|
59
|
// construct a map with the above options
|
60
|
map = new OpenLayers.Map('map', options);
|
61
|
|
62
|
// create Google layer
|
63
|
var gsat = new OpenLayers.Layer.Google(
|
64
|
"Google Satellite",
|
65
|
{type: G_SATELLITE_MAP, sphericalMercator: true}
|
66
|
);
|
67
|
|
68
|
// create Virtual Earth layer
|
69
|
var veaer = new OpenLayers.Layer.VirtualEarth("Bing maps", {
|
70
|
type: VEMapStyle.Aerial, sphericalMercator: true
|
71
|
});
|
72
|
|
73
|
// create Yahoo layer (only the default layer works, the hibrid and the
|
74
|
// satellite ones do throw exceptions and rendering goes totally bye bye)
|
75
|
var yahoosat = new OpenLayers.Layer.Yahoo("Yahoo", {
|
76
|
sphericalMercator: true
|
77
|
});
|
78
|
|
79
|
// you can create your own layers here
|
80
|
|
81
|
// create WMS layer
|
82
|
var wms = new OpenLayers.Layer.WMS(
|
83
|
"TOPP States",
|
84
|
"http://localhost:8080/geoserver/wms?",
|
85
|
{
|
86
|
layers: 'topp:states',
|
87
|
styles: '',
|
88
|
srs: 'EPSG:4326',
|
89
|
format: 'image/png',
|
90
|
tiled: 'true',
|
91
|
tilesOrigin : "143.60260815000004,-43.851764249999995",
|
92
|
transparent: true
|
93
|
},
|
94
|
{
|
95
|
'opacity': 0.75, 'isBaseLayer': false, 'wrapDateLine': true
|
96
|
}
|
97
|
);
|
98
|
|
99
|
var usBounds = new OpenLayers.Bounds(
|
100
|
-14392000, 2436200, -7279500, 6594375
|
101
|
);
|
102
|
|
103
|
// add the created layers to the map
|
104
|
// (if you want custom layers to show up they must be here as well)
|
105
|
map.addLayers([gsat, veaer, yahoosat, wms]);
|
106
|
|
107
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
108
|
map.addControl(new OpenLayers.Control.MousePosition());
|
109
|
map.zoomToExtent(usBounds);
|
110
|
|
111
|
// the part below is just to make the bounds show up on the page
|
112
|
var boundsOutput = document.getElementById('bounds');
|
113
|
function updateBounds() {
|
114
|
var code =
|
115
|
" var bounds = new OpenLayers.Bounds(\n" +
|
116
|
" " + map.getExtent().toBBOX().replace(/,/g, ', ') + "\n" +
|
117
|
" );\n" +
|
118
|
" map.zoomToExtent(bounds);"
|
119
|
boundsOutput.innerHTML = code;
|
120
|
}
|
121
|
// update the bounds with each map move
|
122
|
map.events.register('moveend', map, updateBounds);
|
123
|
// and update the bounds on first load
|
124
|
updateBounds();
|
125
|
}
|
126
|
|
127
|
</script>
|
128
|
</head>
|
129
|
<body onload="init()">
|
130
|
<h3>Geoserver OpenLayers Demo</h3>
|
131
|
<div id="map"></div>
|
132
|
<p>In creating your own OpenLayers application, you can use the bounds shown
|
133
|
above as your initial extent. For example, the following code would zoom
|
134
|
your map to the current extent:
|
135
|
</p>
|
136
|
<pre id="bounds"></pre>
|
137
|
</body>
|
138
|
</html>
|