This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wms.html
132 lines (101 loc) · 3.96 KB
/
wms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="lib/ol/theme/default/style.css" type="text/css" />
<script src="lib/ol/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer, xxx=0;
var cache = {}
function init(){
map = new OpenLayers.Map('map',{
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"), //v metrech pro mercatora
displayProjection: new OpenLayers.Projection("EPSG:4326"), //latlon
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.OverviewMap(),
new OpenLayers.Control.MousePosition()]
});
var hackedLayer = new OpenLayers.Layer.WMS("UHUL", "http://www.localhost/osmcz/proxy.php/http://geoportal2.uhul.cz/wms_oprl/",
{
layers: 'Ortofoto_cb'
},
{
attribution: "© 2000 <a href='http://www.uhul.cz/'>ÚHUL</a>",
isBaseLayer: true,
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
maxResolution: 156543.0339,
numZoomLevels: 20,
units: "m",
projection: "EPSG:4326"
});
hackedLayer.getFullRequestString = function(newParams, altUrl) {
this.params.SRS = "EPSG:4326";
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this, arguments);
}
hackedLayer.getURL = function(bounds){ //this solution too slow, must be cached (cache could grow too biggg!)
var id = bounds.toBBOX();
if(!cache[id])
cache[id] = toLL(bounds.clone());
return OpenLayers.Layer.WMS.prototype.getURL.apply(this, [ cache[id] ]);
}
//document.getElementById('docs').innerHTML = ""+bounds.left+""+bounds.top
map.addLayer(hackedLayer);
//Mapnik layer
map.addLayer(new OpenLayers.Layer.OSM("Mapnik", null, {
isBaseLayer: false,
opacity: 0.4
}));
//CUZK
var hackedLayer = new OpenLayers.Layer.WMS("CUZK", "http://wms.cuzk.cz/wms.asp",
{
layers: 'prehledka_kat_uz,prehledka_kraju-linie',
transparent: true
},
{
attribution: "© 2011 <a href='http://www.cuzk.cz/'>ČÚZK</a>",
isBaseLayer: false,
visible: false,
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
maxResolution: 156543.0339,
numZoomLevels: 20,
units: "m",
projection: "EPSG:4326"
});
hackedLayer.getFullRequestString = function(newParams, altUrl) {
this.params.SRS = "EPSG:4326";
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this, arguments);
}
hackedLayer.getURL = function(bounds){ //this solution too slow, must be cached (cache could grow too biggg!)
var id = bounds.toBBOX();
if(!cache[id])
cache[id] = toLL(bounds.clone());
return OpenLayers.Layer.WMS.prototype.getURL.apply(this, [ cache[id] ]);
}
//document.getElementById('docs').innerHTML = ""+bounds.left+""+bounds.top
map.addLayer(hackedLayer);
map.setCenter( fromLL(new OpenLayers.LonLat(14.3, 50.1)), 14);
//map.setCenter( new OpenLayers.LonLat(14.3, 50.1), 14);
}
function toLL(obj){return obj.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));}
function fromLL(obj){return obj.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));}
</script>
</head>
<body onload="init()">
<h1 id="title">WMS Example</h1>
<div id="tags">
</div>
<p id="shortdesc">
Shows the basic use of openlayers using a WMS layer
</p>
<div id="map" class="smallmap" style="width:400px;height:400px"></div>
<div id="docs">
This is an example of how to add an WMS layer to the OpenLayers window. The images are tiled in this instance if you wanted to not use a tiled WMS
please use this example and pass the option ‘singleTile’ as true.
</div>
</body>
</html>